Jump to content

"Duplicate ID" error - but how else to do it?


Bert Coules

Recommended Posts

My newly-revamped site is now live at http://www.bertcoules.co.uk . Thanks again for all the help.

 

I ran the coding through the W3C markup validator. It picked up this in index.php which is reported as a "Duplicate ID" error:

            <div id="caption_bar">                <p class="caption"> Sherlock Holmes </p>            </div>            <div id="caption_bar">                <p class="caption"> A Wizard of Earthsea </p>            </div>            <div id="caption_bar">                <p class="caption"> Lost Empires </p>            </div>            <div id="caption_bar">                <p class="caption"> Mutiny on the Bounty </p>            </div>

Is this bad practice? It certainly seems to work, and does exactly what I want it to, with the "caption_bar" set to span a quarter of the overall width of the display, but is there a more legitimate way of doing it?

 

Many thanks.

Edited by Bert Coules
Link to comment
Share on other sites

Yes, there's a better way. Use a class name instead of an id.

<div class="caption_bar">

 

The purpose of an ID is to identify a single unique item on the page.

 

If you scroll just a bit further on this page you'll find the class selector: http://www.w3schools.com/css/css_selectors.asp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...