Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: CSS: white-space property with SPAN?


Message #1 by mcfann@u... on Thu, 9 May 2002 09:52:29
> mcfann@u... wrote:

>Subject: CSS: white-space property with SPAN?
>From: mcfann@u...
>Date: Thu, 9 May 2002 09:52:29
>X-Message-Number: 1
>
>According to the CSS2 standard, the white-space property applies only to 
>block-level elements.  Yet I have found that
>
>span {white-space: nowrap}
>
>works in IE 6 and Netscape 6.2.
>
>Does this mean that SPAN is a block-level element?  Or that block-level 
>properties apply to it for some reason?  Or am I misunderstanding 
>something.
>
>Thanks,
>
>Brian
>  
>
Hello Brian,

The Gecko engine only supports CSS1 fully but since CSS1 also says 
white-space applies to block level elements I'd have to see what you're 
HTML looks like before I could say for sure. According to the standard a 
UA is free to ignore the style sheet and use the default which for SPAN 
means you have to use a BR tag for line breaks since it's an inline 
element.

John


John

O.K., this is what my HTML looks like:

1.&nbsp;<span class="name">Brian McFann</span>, 2.&nbsp;<span 
class="name">John Wm. Wicks</span>, 3.&nbsp;<span class="name">Joe 
Blow</span>,

and 10 to 15 more of the same, with style sheet rule

span.name {white-space: nowrap}

It is a list of names (in a picture caption) and (and for ease of reading) 
I don't want browsers to put a line break between a number and a name, or 
between a first and last name.  I would like to use an element like SPAN 
to encapsulate names, rather than putting a &nbsp; between first and last 
names, because it is easier to proof-read and edit the names that way (and 
I might also like to apply other stylesheet rules to names, so it is 
useful to identify names in the HTML as a logically distinct sort of 
text).  When I size the width of the window in IE 6 and Netscape 6.2 down 
as far as it will go, these browsers obey the rule and refuse to break 
apart names.  I am wondering if this is according to standard (and so 
behavior that I can count on) or if this is non-standard behaviour.  If it 
is according to the CSS2 standard, then there is something that I am 
misunderstanding about the standard, since the standard says that 
the "white-space" property applies only to block-level elements.  I would 
like my HTML and style sheet to conform to the W3C standards, so I would 
like to know for sure whether my use of the "white-space: nowrap" rule 
with SPAN does or doesn't conform to the CSS2 standard. 

Brian  

  Return to Index