Re: CSS equivalent to the NOBR tag?

Hakon Lie writes:
 > Andrew n marshall wrote:
 > 
 >  > I noticed the whitespace tag only applies to block level elements.  Is there
 >  > any equivalent to this for inline elements, similar to the use of NOBR in
 >  > HTML? 
 > 
 > Yes, the 'white-space' property takes a 'nowrap' value [1]. So, you
 > can e.g. say:
 > 
 >    CODE { white-space: nowrap }
 >
 > [1] http://www.w3.org/TR/REC-CSS1#white-space

I think the question was about inline level elements, and there CSS
indeed has no way to suppress line breaks. You'll have to use  
in the source document.

In the next level of CSS, you may be able to achieve the effect, but
in a slightly different way: a new value 'inline-block' has been
proposed for the 'display' property, to create (multi-line) blocks in
the middle of a line (e.g., for the BUTTON element of HTML). Using
that, you could do:

    CODE {
      display: inline-block;    /* put CODE into an inline block */
      whitespace: nowrap;       /* keep all contents on one line */
      width: auto;              /* make as narrow as possible */
      vertical-align: baseline; /* align at first baseline */
    }

(The last two properties are initial values, and could usually be
omitted.) Assuming no further margins, borders, etc. this should have
the desired visual effect.

(People that know TeX should be familiar with this: to keep things on
one line, you put them in an \hbox.)

Maybe you can already do this in CSS2 (at least in theory) by
(ab)using the 'inline-table', although I have to think a bit about the
alignment:

    CODE {
      display: inline-table;
      whitespace: nowrap;
    }


Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Monday, 28 September 1998 07:11:17 UTC