W3C home > Mailing lists > Public > www-style@w3.org > May 2002

Re: Difference between class and id

From: Timothy J. Luoma <luomat@peak.org>
Date: Mon, 27 May 2002 12:54:41 -0400 (EDT)
Message-ID: <Pine.WNT.4.44.0205271250290.3960-100000@Tim>
To: Gabriel <ghrivera@sinectis.com.ar>
cc: hwg-style@hwg.org, <www-style@w3.org>
On Mon, 27 May 2002, Gabriel wrote:

> What's the difference between using <div id=smth> and <div class=smth>
> (and <div id=smth1 class=smth2>)?
> Are they supposed to have different content?

Basically, you can only have one ID of a certain value per page, but you
can reuse classes all you want.

For example, this would be legal to have on one page

<div id="top" class="paragraph"> .... </div>

<div id="middle" class="paragraph"> .... </div>

<div id="bottom" class="paragraph"> .... </div>

but this would not:

<div id="paragraph"> ... </div>

<div id="paragraph"> ... </div>

<div id="paragraph"> ... </div>

You can also make links to 'id' tags

'id' tags can also be used for other elements other than DIV


ps -- be sure to quote your values in class and id and other attributes...
using lowercase is also good.... you'll thank me one day when you start to
use XML/XHTML for the habits you develop today
Received on Monday, 27 May 2002 13:11:31 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:02 UTC