homepage Welcome to WebmasterWorld Guest from 54.235.16.159
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

    
CSS Sprites - same id twice
stassaf




msg:4568684
 1:22 pm on Apr 28, 2013 (gmt 0)

Hi,
i'm getting a W3C validation error for:
ID "xx" already defined
these are logos which appear a few times on the same page.

for example:

CSS:
.spMiniLogos {
background: url(images/Logos/spMiniLogos.png) no-repeat top left;
}
#sRED{ background-position: 0 0; width: 40px; height: 10px;}
#sBlue{ background-position: 40 0; width: 40px; height: 10px;}

HTML:
<div class="spMiniLogos" id="sRED"></div>
...
<div class="spMiniLogos" id="sBlue"></div>
....
<div class="spMiniLogos" id="sRED"></div>



so the ID "sRED" appears a few times on the same page and it can't be validated.

i can't create unique ID for each cause it's build dynamically and i don't know how many times the element will appear.

do you have a solution for this issue.

Thanks!
Assaf.

 

rainborick




msg:4568691
 1:49 pm on Apr 28, 2013 (gmt 0)

Whenever you may use a CSS ruleset more than once on a page, it's an indication that you might want to use a class instead of an ID.

CSS:
.spMiniLogos {
background: url(images/Logos/spMiniLogos.png) no-repeat top left;
}
.sRED{ background-position: 0 0; width: 40px; height: 10px;}
.sBlue{ background-position: 40 0; width: 40px; height: 10px;}

HTML:
<div class="spMiniLogos sRED"></div>
...
<div class="spMiniLogos sBlue"></div>
....
<div class="spMiniLogos sRED"></div>

stassaf




msg:4568692
 1:59 pm on Apr 28, 2013 (gmt 0)

PEREFCT!
thanks

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved