Forum Moderators: not2easy

Message Too Old, No Replies

div ID vs div class

         

bj75

5:19 am on Nov 3, 2005 (gmt 0)

10+ Year Member



I have my page looking how I want it using stict xhtml.

<No URLs, thanks. See TOS [WebmasterWorld.com] and CSS Forum Charter [WebmasterWorld.com]>

Ive started the daunting task to try and validate my code on wc3 validator. I have used several div id on the same page which I have read is a no no and the validator reports them as an issue.

So i changed my code to div class all except the div id="nav" on the left menu. When I do this however all my neat formatting was lost.Basically it threw each product under the last line of text from the previous product and omitted my blue line which is a bottom border of the divs product box.

CAn anyone tell me why this is happenning?

Thanks in advance

[edited by: DrDoc at 7:19 am (utc) on Nov. 3, 2005]

Robin_reala

7:19 am on Nov 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, ids are 10 times more specific than classes in CSS. Have a look at this recent thread [webmasterworld.com] for more info.

DrDoc

7:21 am on Nov 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, have you changed the style sheet to reflect the switch from IDs to classes? E.g. instead of:

#myidentifier {
/* rules here */
}

Have you changed it to:

.myidentifier {
/* rules here */
}

Otherwise, what Robin_reala just said is probably why. Classes are not as "specific" as IDs.