span with width or inline div

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Thies

    span with width or inline div

    I have something like this:

    <span style="width:12 ex; text-align: right">field label</span><input
    type="text" ...>

    (I suppose it may be better to do that with label. I'm not really sure
    what that tag is about.)

    that emulates this ever popular table layout (but is foldable):

    <tr><td align="right">f ield label</td><td><input type="text"
    ....></td></tr>

    What I don't remember is whether giving spans widths is legal or not?
    This could be done with inline divs, but I seem to recall that either
    isn't legal or Opera is not fond of them. Which is it?

    Jeff
  • Brian

    #2
    Re: span with width or inline div

    Jeff Thies wrote:[color=blue]
    >
    > <span style="width:12 ex; text-align: right">field label</span><input
    > type="text" ...>
    >
    > (I suppose it may be better to do that with label.[/color]

    Yes, it would.
    [color=blue]
    > I'm not really sure what that tag is about.)[/color]

    < http://www.w3.org/TR/html401/interact/forms.html#h-17.9 >
    [color=blue]
    > that emulates this ever popular table layout (but is foldable):
    >
    > <tr><td align="right">f ield label</td><td><input type="text"
    > ...></td></tr>
    >
    > What I don't remember is whether giving spans widths is legal or not?[/color]

    No. Inline elements cannot have a width set.
    [color=blue]
    > This could be done with inline divs, but I seem to recall that either
    > isn't legal or Opera is not fond of them. Which is it?[/color]

    I don't know about Opera. But declaring a div (or any block level
    element) as inline would, I think, then preclude setting a width.

    My advice:
    use label, since it assigns semantic meaning to the input labels.
    Float them left, essentially making them block level. Declare a
    width. Note that, in NS6/Mac (and possibly NS6/Win), floating a label
    element makes it disappear entirely! IIRC, putting the actual text in
    a span element, and floating that fixes it. I can't find the post at
    the moment. I'll continue looking, and post a link if I find it.

    --
    Brian
    follow the directions in my address to email me

    Comment

    Working...