W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2008

[whatwg] The div element

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 31 Jul 2008 00:44:56 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0807310026100.3299@hixie.dreamhostps.com>
On Thu, 28 Feb 2008, Geoff Pack wrote:
> 
> Why does the HTML5 spec say "The div element represents nothing at all"? 
> [http://www.whatwg.org/specs/web-apps/current-work/#the-div]
> 
> Div clearly stands for 'division', as was specified in the HTML 3.2 
> spec: "DIV elements can be used to structure HTML documents as a 
> hierarchy of divisions." [http://www.w3.org/TR/REC-html32#div]
> 
> So what gives - why is everyone so keen to claim that 'div' is 
> meaningless? And why so keen on 'section', which is pretty much 
> synonymous in this context.

<section> and <div> have very different semantics. <section> describes a 
section of a document, e.g. a chapter or a scene.

<div> is a generic element used for grouping and structure when there's 
nothing better to use. If we said it represented a "division", then there 
would be nothing left over to represent "nothing".

For example, people want to do things like:

   <div class="chart-control">
    <div class="chart-panel">
     <div class="toolbar">
      <div class="zoom-control"> ... </div>
      <div class="dates"> ... </div>
      <div class="legend"> ... </div>
     </div>
     <div class="chart"> ... </div>
    </div>
    <div class="timeline">
     <div class="background"> ... </div>
     <div class="active-indicator"> ... </div>
     <div class="scroller-control"> ... </div>
    </div>
   </div>

...to represent something like the stock chart widget on Google Finance.

These aren't divisions. They're nothing, just places to hang styles from 
because HTML isn't good enough to natively have a stock chart control.


On Thu, 28 Feb 2008, Dave Hodder wrote:
> 
> Personally I'd describe it more along the lines of:
> 
> "The div element is a generic way of representing document structure, 
> but offers no further semantics.  Where appropriate, elements with more 
> specific meanings (such as section or aside) should be used instead. Use 
> of the div element may be appropriate for extended features not covered 
> by this specification, for example a new type of user interface 
> control."

I don't think the <div>s in the example above are "representing document 
structure" in anything more than the most technical of senses.


On Thu, 28 Feb 2008 html at nczonline.net wrote:
>
> I'm still not clear to me how <section/> is anything more than a <div/>. 
> HTML4 said: "The DIV and SPAN elements, in conjunction with the id and 
> class attributes, offer a generic mechanism for adding structure to 
> documents" (http://www.w3.org/TR/html401/struct/global.html#edef-DIV). 
> Isn't that the very thing that <section/> is trying to do? Provide 
> structure? I don't see that it offers anything over and above what 
> <div/>s do now, except for confusing developers as to which is more 
> appropriate to use.

The difference is that <section> elements appear in the table of 
contents, basically.


On Fri, 29 Feb 2008, Tab Atkins Jr. wrote:
>
> In HTML5, the <hx> hierarchy is explicitly ignored.  Instead, they're 
> all treated the same.  The actual heading level is determined by 
> <section> nesting.

(This isn't completely true, but it is true that the rank of headers only 
affects headers withint the same sectioning element.)


> Question to others:  I think it is somewhat unclear what exactly the 
> correct semantics are for <section> when it is encountered outside of an 
> <article>. Since <section> is the most generic of the sectioning tags, 
> there is a definite risk of it falling into the same hole that <div> is 
> in.  Where exactly should <section> be used when outside of an article, 
> and when should we just default to the <div>?

<article> isn't needed if there's only one article on the page, or if the 
page is part of a large set of documents forming a single "article" or 
book-equivalent.


On Mon, 3 Mar 2008, Geoff Pack wrote:
> 
> After following the discussion, I?m still not any clearer about the 
> difference between sections and divs. But no matter. What I?m bothered 
> about is not which to use where, but the description in the spec. I 
> think it should be changed from:
> 
>     ?The div element represents nothing at all.?
> 
> To something like:
> 
>     "The div element represents a document division. It can (also)
>     be used as a generic block-level element"

If something represents both A and not-A, then it represents nothing, 
effectively, since you can't tell which meaning is being used at any one 
time. Hence, the <div> element represents nothing.


> Similarly, the definition of the span element should be changed from:
> 
>     "The span element doesn't mean anything on its own..."
> 
> To:
> 
>     "The span element represents an arbitrary span of text."

The text itself represents the arbitrary span of text. The <span> element 
doesn't add anything to the meaning of the document on its own. That's 
what the spec is saying.


> Strangely enough, both the <b> and <i> elements begin:
> 
>     "The .. element represents a span of text..."

Both of those sections immediately elaborate about the special 
characteristics that they introduce to those spans.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 30 July 2008 17:44:56 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:04 UTC