CSS: Value for display to avaid line breaking ?

Discussion in 'HTML' started by Matthias Pospiech, Feb 20, 2005.

  1. I define a class url
    ..url
    {
    display: ??;
    color: #606060;
    }

    which is used as

    <li>
    <a href="http://www.tug.org/interest.html">TeX Resources on the Web</a>
    <span class="url">http://www.tug.org/interest.html</span></li>

    now I want the span to be a block, ie. to break in to the next line if the
    url does not fit into the current one.

    What kind of value for display is the correct on in that case ?
    I tried "block", but that puts it always in the next line.

    Matthias
     
    Matthias Pospiech, Feb 20, 2005
    #1
    1. Advertising

  2. Matthias Pospiech

    Toby Inkster Guest

    Matthias Pospiech wrote:

    > now I want the span to be a block, ie. to break in to the next line if the
    > url does not fit into the current one.


    You are misunderstanding what a block is.

    You probably want:

    white-space: nowrap;

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Feb 20, 2005
    #2
    1. Advertising

  3. Toby Inkster wrote:

    > Matthias Pospiech wrote:
    >
    >> now I want the span to be a block, ie. to break in to the next line if
    >> the url does not fit into the current one.

    >
    > You are misunderstanding what a block is.

    Maybe - any information ?

    > You probably want:
    >
    > white-space: nowrap;

    It work, though an URL has no white space...

    Matthias
     
    Matthias Pospiech, Feb 20, 2005
    #3
  4. Matthias Pospiech <> wrote:

    > I define a class url
    > .url
    > {
    > display: ??;
    > color: #606060;
    > }


    You should always specify background whenever you specify color.
    What if the user's style sheet contains
    * { background: #606060; color: black; }
    ?

    > <li>
    > <a href="http://www.tug.org/interest.html">TeX Resources on the
    > Web</a> <span
    > class="url">http://www.tug.org/interest.html</span></li>
    >
    > now I want the span to be a block, ie. to break in to the next line if
    > the url does not fit into the current one.


    That's not what "block" means. A block unconditionally begins on a new line
    (unless you do something else explicitly).

    > What kind of value for display is the correct on in that case ?


    The value inline, which is the default value, so it need not be specified.

    Toby's suggestion of using white-space: nowrap might be what you are after.
    Contrary to its name - CSS property names are often misleading - it
    prevents line breaks inside the content, except for explicitly created
    breaks (e.g., <br>). Thus it may prevent a browser from splitting after "/"
    for example. Whether this is a good thing to do is a different issue.

    Normally URLs should appear as attribute values, not in document content
    proper. Have you ever listened to a speech browser reading URLs? It doesn't
    actually improve the experience. It's sufficient to have the link there.

    If you wish to include a URL for _printed_ copies, then again this might
    not be a good idea. The URL of the page itself is usually sufficient and
    can be included into the printed copy by the user if desired, and many
    browsers can automatically generate a list of URLs appearing in links.

    But if you do include a URL into document content proper, I would recommend
    using quotation marks or the characters "<" and ">" as delimiters and
    encourage (rather than discourage) browsers into splitting a URL across
    lines, as described in more detail at
    http://www.cs.tut.fi/~jkorpela/html/nobr.html#url

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Feb 20, 2005
    #4
  5. Matthias Pospiech

    Toby Inkster Guest

    Matthias Pospiech wrote:
    > Toby Inkster wrote:
    >
    >> You are misunderstanding what a block is.

    >
    > Maybe - any information ?


    A block is a chunk of text that starts on a new line and ends with a line
    break.

    Examples of blocks are:

    - a paragraph
    - a list item (like this)
    - a heading

    So a block begins and ends with a line break, but that's not to say that
    it can't have line breaks in between. A reasonably long paragraph, such as
    this one, will extend onto several lines, but is considered as a block.

    >> You probably want:
    >> white-space: nowrap;

    >
    > It work, though an URL has no white space...


    As Jukka said, CSS properties are often oddly named.

    Consider there is a "background-color" but no "foreground-color". To make
    things bold you use "FONT-weight", but to underline them you use
    "TEXT-decoration".

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Feb 20, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Afonin
    Replies:
    4
    Views:
    428
    Natty Gur
    Jul 10, 2003
  2. DeepDiver
    Replies:
    3
    Views:
    673
  3. \(.  \)\(  .\) siorbaj cycka

    <a title=""> tag and line breaking

    \(. \)\( .\) siorbaj cycka, Nov 7, 2004, in forum: HTML
    Replies:
    6
    Views:
    455
    Jukka K. Korpela
    Nov 7, 2004
  4. Amy
    Replies:
    0
    Views:
    519
  5. Klaus Cammin

    Free line breaking

    Klaus Cammin, Jul 11, 2006, in forum: HTML
    Replies:
    53
    Views:
    1,343
    Jonathan N. Little
    Jul 16, 2006
Loading...

Share This Page