# Re: CSS equivalent to the NOBR tag?

From: Bert Bos <Bert.Bos@sophia.inria.fr>
Date: Mon, 28 Sep 1998 13:11:11 +0200 (MET DST)
To: "Andrew n marshall" <amarshal@usc.edu>, "W3C Style List" <www-style@w3.org>
Message-ID: <13839.26847.772010.454834@www43.inria.fr>
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 &nbsp;
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:56 GMT