Jump to content

<div id = "hello">


Max Castril

Recommended Posts

Interesting problem with the W3 schools checker 'Nu Html Checker'.

I am using a CSS file that I have written which includes a reference 'area1'.

I am calling it on many occasions e.g. <a href="mountains.php"  id = "area1">Mountains</a> as I only want 'Mountains' to be affected by this particular CSS. 

When I run Nu Htnl Checker, I get this:

Error: Duplicate ID area1.

From line 330, column 148; to line 330, column 185

></td><td><a href="mountains.php" id = "area1">Mounta

Surely I can use a piece of CSS more than once in an html document??

 

Edited by Max Castril
Link to comment
Share on other sites

If you want to apply a style to multiple elements, use the class attribute.

The ID attribute is intended to identify one specific element on the page, it is designed that way to make accessing elements in Javascript more efficient. Instead of traversing the DOM tree, the browser already has pointers directly to all the elements that have IDs.

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...