Re: Difference between class and id

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

TjL

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