Re: display property

On Thu, 2003-06-26 at 13:45, Jens Meiert wrote:
> > By default, everything is 'display: inline'.
> 
> That's not true. Simply test a page including
> 
>       <p>A paragraph.</p>
>       <p>A second paragraph.</p>
>       <p>Yes, a third.</p>
> 
> and look at it. Now add
> 
>       p { display: inline; }
> 
> to your CSS and see the result. There is no 'display: inline' default, in no
> browser.
> 
> I see Brian's point, and I would change the example, but not the
> implementation. It is the same thing like some people writing
> 
>      b { font-weight: bold; }
> 
> to their code.
> 


So to further clarify.

In the first example display: block is redundant and though it gives the
desired effect which is to vertically align the img element one after
another the more appropriate solution would perhaps be the second
example? And is the fact that the first example works as desired just
another quirk of non-compliancy from most browsers? If I understand
correctly it should not be necessary to define a value of block for the
display property on a block level element if indeed this works the way I
originally suggested.

#lines {
        display: block;
}

<div id="lines">
<img src="xxx" />
<img src="xxx" />
<img src="xxx" />
</div>


#lines > img {
        display: block;
}

<div id="lines">
<img src="xxx" />
<img src="xxx" />
<img src="xxx" />
</div>



> > 
> > On Thu, 26 Jun 2003, Brian V Bonini wrote:
> > >
> > > As I understand it the display property with a value of block will apply
> > > block level formatting to the element it's defined for, e.g. img
> > > {display: block} that being the case why does the recommendation cite
> > > many such examples as:  p{display: block;} is this not redundant since p
> > > is already a block level element and furthermore confusing.
> > 
> > The terms "block level" in an HTML context and "block level" in a CSS
> > context are unrelated. It is quite possible, legal, and often useful, to
> > write things such as:
> > 
> >    p { display: table-cell; }
> >    span { display: block; }
> >    tr { display: inline; }
> > 
> > This does not in any way affect the meaning of the elements, nor their
> > allowed positions in the HTML markup, it merely changes what they look
> > like.
> > 
> > By default, everything is 'display: inline'. Thus, the rule
> > 
> >    p { display: block; }
> > 
> > ...is actually needed somewhere to get the usual effect that is expected.
> > User agents put this rule in the user agent stylesheet, so authors do not
> > have to put it in theirs.
> > 
> > HTH,
> > -- 
> > Ian Hickson                                      )\._.,--....,'``.    fL
> > "meow"                                          /,   _.. \   _\  ;`._ ,.
> > http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'
> > 

Received on Thursday, 26 June 2003 15:05:27 UTC