Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Another "morality" question: ID or class?

Reply
Thread Tools

Another "morality" question: ID or class?

 
 
spaghetti
Guest
Posts: n/a
 
      09-23-2003
I know the technical differences between ID and class, but when (in a
zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
or class?

I'm assuming class should be used almost all the time, especially when
working with style sheets, and that ID should only be used to reference
particular sections of a document from other documents?




 
Reply With Quote
 
 
 
 
Adrienne
Guest
Posts: n/a
 
      09-23-2003
Gazing into my crystal ball I observed "spaghetti" <>
writing in news:VL_bb.2102$ nk.net:

> I know the technical differences between ID and class, but when (in a
> zen/standards/schematic/just-to-be-good sense) is it appropriate to use
> ID or class?
>
> I'm assuming class should be used almost all the time, especially when
> working with style sheets, and that ID should only be used to reference
> particular sections of a document from other documents?
>
>


<div id="header">
<ul><li>menu item 1</li></ul>
</div>
<div id="content">
<h1 class="titles" id="header1">Title</h1>
<p>Something</p>
</div>
<div id="footer">
Copywrite ...<a href="#header1">Head</a>
</div>


Very nice for making templates, especially templates using include files.
--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
 
Reply With Quote
 
 
 
 
Kae Verens
Guest
Posts: n/a
 
      09-23-2003
spaghetti wrote:
> I know the technical differences between ID and class, but when (in a
> zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
> or class?
>
> I'm assuming class should be used almost all the time, especially when
> working with style sheets, and that ID should only be used to reference
> particular sections of a document from other documents?


id is for unique items - ie: there should only be one specific id per page
class is for common items - ie: items which share common features could
be of the same class

for example, I have the id "Kae Verens", and am of the class "web
developer" - the id is unique, but the class is common.

Kae

 
Reply With Quote
 
PTG
Guest
Posts: n/a
 
      09-23-2003

"spaghetti" <> wrote in message
news:VL_bb.2102$ nk.net...
> I know the technical differences between ID and class, but when (in a
> zen/standards/schematic/just-to-be-good sense) is it appropriate to use ID
> or class?
>
> I'm assuming class should be used almost all the time, especially when
> working with style sheets, and that ID should only be used to reference
> particular sections of a document from other documents?


You use ID when there's just one instance of an element you want styling.
You use class when there are multiple elements you want to style with one
selector.

Classes should actually be used rarely, because you should be able to use
nested selectors in CSS in most cases (such as '#content p strong {
stuff }')

ID attributes are a good thing to use in HTML because they identify an
element and can also be used for page anchors.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force a load of one control from another control on another form? et ASP .Net 1 06-29-2005 07:45 PM
Renaming a project with another project as the starting point? In another solution Maziar Aflatoun ASP .Net 1 01-22-2005 12:49 AM
How to access: a page from a User control, and another User controlfrom another one? qwerty ASP .Net 3 09-30-2004 05:32 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM
How do I write HTML tags for an applet that imports classes from another jar in another package? Ding Java 1 07-01-2004 03:41 AM



Advertisments