Re: Display

In an attempt to make this whole thing a little clearer for Colt, who, 
like many authors, might not be too familiar with the innards of CSS, 
here's a quick summary (and I hope and expect that someone will correct 
me if I end up being misleading or incorrect!):

The HTML language wants some things (such as headings and paragraphs) to 
behave like chunks stacking vertically down the page; it uses the term 
"block-level" to describe them.  It wants other things (such as text) to 
flow horizontally along the page; it uses the term "inline-level" to 
describe them.

CSS wants to take responsibility for the styling of HTML, leaving HTML 
to merely describe the semantics ("meaning") of the elements.  Authors 
were very much accustomed to the behaviour of the block-level and 
inline-level things already specified by HTML, and so it was natural 
that CSS needed to be able to describe these two behaviours itself. 
Hence along came display:block and display:inline, which can be applied 
to elements as the author sees fit.

CSS defines an "initial" value for every property, including the 
'display' property, which is typically used for any document element 
which didn't have a value for that property explicitly specified by the 
author.  There can only be one initial value of each property, and 
interestingly the initial value of the 'display' property is "inline", 
and so, if there were no more to it than this, everything that CSS 
controlled would flow-and-wrap like text unless the author specified 
otherwise.

Now, authors don't want to have to specify everything!  And CSS can't 
turn to the document language for hints about which elements should have 
which behaviour for the unspecified things, since it is designed to not 
be tied to a particular document language(*) (Mozilla Firefox uses a 
non-HTML language to describe its user interface and uses CSS to style 
it, for example).  Thus, by necessity, CSS knows or cares nothing about 
whether HTML specifies that an element known as P or H1 is defined to be 
"block-level".

Instead, User Agent stylesheets are used to provide sensible starting 
values for the various elements in the document language that the User 
Agent deals with.  For example, all mainstream HTML browsers internally 
use either a real CSS stylesheet (or some other internal thing which 
gives the end appearance of using one), and they invariably give all P 
elements display:block and all SPAN elements display:inline, thus 
conforming to authors' expectations about how those elements should 
behave "by default".


Colt's IDE is flawed in its approach, blindly switching from 
display:none to display:inline, which prompted his idea about returning 
to the "default" value.  But what does that mean?  The User Agent 
stylesheet value could be interesting, as Aryeh suggested.  But maybe 
Colt was more interested in "the previous value before he changed it" 
(which was what Marcus and Boris were discussing), or something else. 
(The "initial" value of a property is a red herring, as Boris pointed 
out).  Hence Boris' counter-question requesting clarification.


Cheers,
Anton Prowse
http://dev.moonhenge.net

[1]

Received on Tuesday, 27 April 2010 20:38:58 UTC