Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    id x already defined

    I am trying to learn to be more rigorous with my XHTML and CSS code, and I am starting to validate everything that i do so that i learn the right way. One thing that a validator pointed out was that I had an ID that was already defined.

    But my confusion is this. I have one style defined as #content #description and then another style defined as #restaurant #description.
    Is that consider the same style? I looked at the explanation of the validator and it was more concerned about case-sensitivity than my issue, so it didn't really explain it. My guess is that that should be seen as two different styles. And if somebody can confirm that, then there must be something else wrong, and I can look elsewhere. Thanks for the info guys.
    see this question in my site by wordpress www.freecalltrials.com
    Last edited by lukedamenno1; 05-04-2011 at 04:00 AM.

  2. #2
    Join Date
    Feb 2011
    Thanked 395 Times in 395 Posts
    Basically, to identify elements you can give them an id which must be unique on the web page or a class where multiple elements can have the same class.

    If you have an element with say, id="myDiv" and you have another element on the same page, whether it is the same type of element or not is irrelevant, with id="myDiv" as well, then the w3c validator will be with you.

    So, if you have multiple elements with the same id and you need those elements to have the same identifier values then you need to give them a class with the value set to the original id value.

    In the css, you select an id with #myDiv and you select a class with .myDiv
    I see your link now passes as XHTML Transitional so I assume your issue is resolved.
    Last edited by bullant; 05-04-2011 at 04:16 AM.

  3. #3
    Senior Coder
    Join Date
    Aug 2010
    High Point, NC
    Thanked 363 Times in 360 Posts
    You can't name two elements with the same id within your html:

    <div id="myID"></div>
    <p id="myID"></p>

    You can have two elements with the same class though.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts