WeLoveCSS Logo
Home Profile Members Search Rules Help New Posts



WeLoveCSS > WEB DESIGN > CSS > [SOLVED] Nested Underline Span

Reply
  Thread Tools Display Modes
Old 31st May 12, 03:14 PM   #1
rob.diazmarino
WLC Member
 
Join Date: May 2012
Posts: 3
Default Nested Underline Span

Hi guys,

I discovered an interesting quirk that is causing me grief.

HTML Code:
<p><span style="text-decoration: underline;">Hello <span style="text-decoration: none;">world</span>!</span></p>
Even though the nested span should remove underlining on "world", the whole text will have the underline style applied. I know it would be easily fixed by not nesting the spans and having them side by side. The problem is, it is critical that I keep this nested structure. Is there any other style I can apply to remove the underlining on "world"?

Much appreciated.
rob.diazmarino is offline   Reply With Quote
Old 31st May 12, 05:38 PM   #2
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
Default Re: Nested Underline Span

Quote:
The problem is, it is critical that I keep this nested structure.
Why??

A span is an inline element, "nesting" them is not usually a "critical" requirement for a layout.

Do we get to see ALL the code so we can see what other rule may be cascading to the span or may have precedence in the flow.
chrishirst is offline   Reply With Quote
Old 31st May 12, 05:48 PM   #3
rob.diazmarino
WLC Member
 
Join Date: May 2012
Posts: 3
Default Re: Nested Underline Span

I'm working with someone else's (complex) code that generates it this way. Changing the styles is easy, changing the structure that it generates is another matter. So I want to make sure there is nothing I can do CSS wise before I dive in to try to rearrange the tag structure.

This nested approach works for bold and italic, it's just underline that's the problem, even in the simplest scenario - no additional style sheets that could be interfering.

HTML Code:
<html>
<head></head>
<body>
<p><span style="font-weight: bold;">Bold <span style="font-weight: normal;">works</span>!</span></p>
<p><span style="font-style: italic;">Italic <span style="font-style: normal;">works</span>!</span></p>
<p><span style="text-decoration: underline;">Underline <span style="text-decoration: none;">no workies</span>!</span></p>
</body>
</html>
rob.diazmarino is offline   Reply With Quote
Old 31st May 12, 07:05 PM   #4
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
Default Re: Nested Underline Span

Quote:
I'm working with someone else's (complex) code that generates it this way.
Ok.

It's an interesting little glitch/effect and not one I have previously come across, and a couple of minutes testing shows it happens with all line type text-decoration values and in all browsers as well, which does suggest that it is intentional.

Hmmm??? Calls for some investigation methinks.
chrishirst is offline   Reply With Quote
Old 31st May 12, 07:22 PM   #5
chrishirst
Banned
 
Join Date: Jun 2006
Location: Blackp ool U.K.
Posts: 3,197
Default Re: Nested Underline Span

Well, excellent question, mainly because I've learnt something in researching the cause.


http://www.w3.org/TR/CSS21/text.html...striking-props
Quote:
When specified on or propagated to an inline element, it affects all the boxes generated by that element, and is further propagated to any in-flow block-level boxes that split the inline
So it is a specified behaviour, and evidence that an old dog can learn new tricks.
chrishirst is offline   Reply With Quote
Old 31st May 12, 07:53 PM   #6
rob.diazmarino
WLC Member
 
Join Date: May 2012
Posts: 3
Default Re: Nested Underline Span

Thanks Chris! It's good to know why this is happening, even if I can't get around it. Time for me to dive into that complex code and whip those spans into shape.
rob.diazmarino is offline   Reply With Quote
Reply


Thread Tools
Display Modes
Linear Mode Linear Mode

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:54 AM.



Home | Advertise | Contact Us | Top
Home | Advertise | Contact Us | Top

Copyright© 2006 WeLoveCSS.com. All Rights Reserved.
Powered by vBulletin Version 3.8.4 Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.