RE: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-10 Thread Trusz, Andrew
 

newbie questions... What is the advantage of the fact that IDs must be
unique on a page? I am aware of the circumstance that if you need to
repeat an ID, set is as a class, but have still not figured out the
advantage of an ID.

¤ devendra ¤

 


In addition to everything else, as id replaces name, id becomes a means to
navigate to parts of a document using the anchor element:  a
id=main/a. 

drew
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-10 Thread Kornel Lesinski
On Thu, 10 Feb 2005 06:40:49 -0500, Trusz, Andrew [EMAIL PROTECTED]  
wrote:

newbie questions... What is the advantage of the fact that IDs must be
unique on a page?
1. getElementById() works.
2. Validation. If you use div id=maincontent, validator will complain  
when you have two or more such divs (typical copypaste accident :)

Additionally IDs have higher priority than class in CSS, so it's easier to  
make local styles for element with an ID than with a class.

--
regards, Kornel Lesiski
**
The discussion list for  http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**


RE: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-10 Thread Mike Pepper
You can address elements from the DOM (Document Object Model) directly via
JavaScript.

Cheers,

Mike Pepper
Accessible Web Developer
Internet SEO and Marketing Analyst
[EMAIL PROTECTED]
http://www.visidigm.com

Administrator
Guild of Accessible Web Designers
[EMAIL PROTECTED]
http://www.gawds.org

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Behalf Of Trusz, Andrew
 Sent: 10 February 2005 11:41
 To: 'wsg@webstandardsgroup.org'
 Subject: RE: [WSG] Not and IE bug?...follow up difference why a
 difference between IDs and classes?




 newbie questions... What is the advantage of the fact that IDs must be
 unique on a page? I am aware of the circumstance that if you need to
 repeat an ID, set is as a class, but have still not figured out the
 advantage of an ID.

 ¤ devendra ¤


 

 In addition to everything else, as id replaces name, id becomes
 a means to
 navigate to parts of a document using the anchor element:  a
 id=main/a.

 drew
 **
 The discussion list for  http://webstandardsgroup.org/

  See http://webstandardsgroup.org/mail/guidelines.cfm
  for some hints on posting to the list  getting help
 **

 --
 No virus found in this incoming message.
 Checked by AVG Anti-Virus.
 Version: 7.0.300 / Virus Database: 265.8.6 - Release Date: 07/02/05


**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



RE: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-10 Thread Trusz, Andrew
 

-Original Message-
From: [EMAIL PROTECTED] On Behalf Of Kornel Lesinski
Sent: Thursday, February 10, 2005 7:09 AM
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] Not and IE bug?...follow up difference why a difference
between IDs and classes?
 newbie questions... What is the advantage of the fact that IDs must be 
 unique on a page?

1. getElementById() works.
2. Validation. If you use div id=maincontent, validator will complain
when you have two or more such divs (typical copypaste accident :)

Additionally IDs have higher priority than class in CSS, so it's easier to
make local styles for element with an ID than with a class.

--
regards, Kornel Lesiski

*

While true all those points had already been mentioned and weren't the point
in any case. The point was that you can create links to parts of documents
using id:
www.mysite.com/mypage.html?id=#myidea

drew 
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



RE: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-09 Thread Devendra Shrikhande
I thought I should pick up on the comment by Peter and ask one of my many 
newbie questions... What is the advantage of the fact that IDs must be unique 
on a page? I am aware of the circumstance that if you need to repeat an ID, 
set is as a class, but have still not figured out the advantage of an ID.

Apologies if this question is not appropriate for this list and should be 
directed more to a CSS-specific list. 

¤ devendra ¤

 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Asquith
Sent: Wednesday, February 09, 2005 3:12 PM
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] Not and IE bug?!?


Hi Peter

Peter Flaschner wrote:
 Well, the clearing didn't do it. At least not as I understand it.

If you're following the lead of the page you mentioned, you will find 
removing the

overflow: hidden;

line from the style sheet should solve your problem. By setting the 
height to zero and then hiding the overflow you're effectively removing 
the clearer block from the page layout. Setting visibility to hidden, on 
the other hand, allows the block to take its specified position and size 
but not be rendered by the browser. I.e. it still takes up the space it 
would have.

I note, too, that your example page contains multiple elements sharing 
the same ID. IDs must be unique for a given page.

Cheers
Peter

-- 
Peter Asquith
http://www.wasabicube.com/
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



RE: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-09 Thread Iain Gardiner
The main advantage of using an ID is simply that it uniquely identifies the
element.  So your CSS or DOM scripting can target it alone.

--
Iain Gardiner
http://www.firelightning.com


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Devendra Shrikhande
Sent: 09 February 2005 22:27
To: wsg@webstandardsgroup.org
Subject: RE: [WSG] Not and IE bug?...follow up difference why a difference
between IDs and classes?


I thought I should pick up on the comment by Peter and ask one of my many
newbie questions... What is the advantage of the fact that IDs must be
unique on a page? I am aware of the circumstance that if you need to
repeat an ID, set is as a class, but have still not figured out the
advantage of an ID.

Apologies if this question is not appropriate for this list and should be
directed more to a CSS-specific list. 

¤ devendra ¤

 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Peter Asquith
Sent: Wednesday, February 09, 2005 3:12 PM
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] Not and IE bug?!?


Hi Peter

Peter Flaschner wrote:
 Well, the clearing didn't do it. At least not as I understand it.

If you're following the lead of the page you mentioned, you will find 
removing the

overflow: hidden;

line from the style sheet should solve your problem. By setting the 
height to zero and then hiding the overflow you're effectively removing 
the clearer block from the page layout. Setting visibility to hidden, on 
the other hand, allows the block to take its specified position and size 
but not be rendered by the browser. I.e. it still takes up the space it 
would have.

I note, too, that your example page contains multiple elements sharing 
the same ID. IDs must be unique for a given page.

Cheers
Peter

-- 
Peter Asquith
http://www.wasabicube.com/
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-09 Thread Peter Asquith
Hi Devendra
Devendra Shrikhande wrote:
What is the advantage of the fact that IDs must be unique on a page? I am aware of the circumstance that if you need to repeat an ID, set is as a class, but have still not figured out the advantage of an ID.
This is an important topic. At first glance, it would seem that there is 
little need for an id attribute - why not use classes everywhere?

However, there's a semantic difference between ids and classes, which is 
this: it's basically the difference between individuals and groups.

An id identifies a specific individual element of the document markup 
and allows CSS to be written that addresses that element specifically. 
In addition, you can reference the id in DOM (Document Object Model) 
scripting to access an element using the getElementById() function.

A class, on the other hand can apply to many elements, not necessarily 
of the same type - you could have a class called warning that is 
applied to h1, p, li and so on to emphasize a warning condition, 
for instance. Another example (which is pertinent to the thread that you 
came in on) is where you want a class to clear floats. It may be that 
you need to apply that class on more than one occasion in a particularly 
fluid layout. By creating a clearer class you can apply it to any 
appropriate block element in order to clear the preceding floats.

Another thing to bear in mind is that ids have higher precedence than 
classes in determining what style is applied to a given element. This 
means that

#myid {
  color: blue;
}
.warning {
  color: red;
}
will colour the element
p id=myid class=warningHello!/p
in blue (despite the fact that the .warning directive appears later in 
the CSS cascade).

(To ensure that it's red you would need to add
#myid.warning {
  color: red;
}
to your stylesheet).
If you carefully lay out your document, with ids for all the main 
display blocks, you can set global class styles and then override them 
on a block-by-block basis via the blocks' ids. So, for instance it might 
be appropriate to display elements with the warning class differently 
in a main content block as opposed a summary block.

Eric Meyer covers this topic well on pages 36-38 of his Cascading 
Stylesheets The Definitive Guide 2nd Edition.

Having said all that, be wary of overusing ids and classes. By using CSS 
selectors carefully, a lot of unnecessary classitis can be avoided.

Hope that helps
Peter
**
The discussion list for  http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**


Re: [WSG] Not and IE bug?...follow up difference why a difference between IDs and classes?

2005-02-09 Thread Ben Curtis

I thought I should pick up on the comment by Peter and ask one of my 
many newbie questions... What is the advantage of the fact that IDs 
must be unique on a page? I am aware of the circumstance that if you 
need to repeat an ID, set is as a class, but have still not figured 
out the advantage of an ID.
If you used absolute positioning, or a background image of the company 
branding, or a structure only appropriate for the main navigation, or 
some other set of styles that should only be rendered if they are 
unique on the, then it is useful to have IDs instead of classes. In 
today's browsers, put multiple IDs on a page and the page is ok, if 
maybe unusually styled. But future browsers are likely to be more 
strict and may display a big fat parse error message for such a page. 
That's a good thing -- it'll help you identify when you accidentally 
gave two id=nav styles to teh same page.

It will be problematic, however, when you combine templates, CMSs, and 
webservices-sourced XML all in one document. This is where we are 
rescued by namespaces and the increasingly common habit of giving IDs 
unique prefixes based on the author.

--
Ben Curtis : webwright
bivia : a personal web studio
http://www.bivia.com
v: (818) 507-6613

**
The discussion list for  http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list  getting help
**