Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthornemeseri
    • CommentTimeFeb 13th 2009
     permalink
    Hi!

    I know that it's clearly invalid when you place a block element inside an inline element (it's generate sometimes strange results in browsers). But is it valid to set an inline element display property to block inside an other - inline containing - element?

    i.e.:
    <span>
    <em style="display: block">some box</em>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    </span>

    i.e. 2. :
    <span>
    <em style="float: left; width: 100px;">some box</em>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    </span>

    I know that it's valid to place an inline-block element inside an inline element (is it?), but what about the other relationships? I can't find any table or explanation of this problem in the CSS spec.

    The spec said (through an example), that inside a <p> tag we can float elements: http://www.w3.org/TR/CSS21/visuren.html#comp-float.
    If we float an element, the display property computed value is block (http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo). The HTML dtd said that we can't place a block element inside a <p> tag. So now what? Is it valid to place a "display: block" inline element inside an other inline element?

    Thanks,
    Andras
  1.  permalink
    Hi Andras,

    You are confusing HTML block level elements with CSS formatting, see W3C.

    The CSS display property is used to change how an HTML element renders for instance a HTML block level element can be made to display inline so that it doesn't force a line break. Adding display:block to an inline element eg <span> does not make it a HTML block level it simply causes it to behave as block when the page renders.

    Hope that clears up your misunderstanding

    Cheers

    John
Add your comments
    Username Password
  • Format comments as (Help)