Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Class and ID Selectors (CSS question)

Reply
Thread Tools

Class and ID Selectors (CSS question)

 
 
Matt Beckwith
Guest
Posts: n/a
 
      07-12-2003
Is there any good reason to use ID selectors? It seems to me they're
effectively the same as class selectors, but limited by only being able to
be used once.


 
Reply With Quote
 
 
 
 
Anders Thorsen Holm
Guest
Posts: n/a
 
      07-12-2003
Matt Beckwith wrote:

> Is there any good reason to use ID selectors? It seems to me
> they're effectively the same as class selectors, but limited by
> only being able to be used once.


As far as I know, they can also be used as targets for internal links.
Example:

<div id="menu">
<ul>
<li><a href="#chp1">Chapter 1</a></li>
<li><a href="#chp2">Chapter 2</a></li>
</ul>
</div>

<div id="chp1">
<h1>Chapter 1: How it all began</h1>
<p>yadda-yadda-yadda</p>
</div>

<div id="chp2">
<h1>Chapter 2: And what happened next</h1>
<p>hummena-hummena-hummena</p>
</div>



Although it - suprise - doesn't seem to work in Netscape 4, but hey, no
loss here.



--
Anders Thorsen Holm | http://www.daimi.au.dk/~zoolook/
"It's hard to be religious when certain people are never incinerated by
bolts of lightning."
- Calvin, Attack of the Deranged Mutant Killer Monster Snow Goons
 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      07-12-2003
Matt Beckwith wrote:

> Is there any good reason to use ID selectors? It seems to me they're
> effectively the same as class selectors, but limited by only being able to
> be used once.


If purely CSS terms, they have a higher specificity, but they are useful for
things beyond CSS.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      07-13-2003
Daniel Doman wrote:

> I guess you could use them as targets in a DIV statement as you suggest.
> But isn't that what anchor tags are for?


What are you taking about? Please quote properly.

After digging around in the archives it appears to be a query are id
attributes to define document fragments for link targetting.

The answer is "no", anchors for fragment identifiers have been superseded by
the id attribute on just about any element.

It makes more sense semantically (IMO) and makes it a lot easier to pull of
tricks such as http://stone.thecoreworlds.net/software/frag/

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
 
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
Sibling selectors and reordering elements eefacm@gmail.com Javascript 3 03-26-2008 01:00 PM
Selectors and modificators trouble Krivenok Dmitry C++ 4 09-13-2005 09:24 PM
Re: Class selector, ID selectors and link pseudo-classes Luigi Donatello Asero HTML 1 06-04-2005 06:58 PM
Class selector, ID selectors and link pseudo-classes Luigi Donatello Asero HTML 4 06-04-2005 05:02 PM
IE on attribute selectors tshad ASP .Net 1 11-12-2004 11:05 PM



Advertisments