Max Castril Posted April 1, 2017 Share Posted April 1, 2017 (edited) 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 April 1, 2017 by Max Castril Link to comment Share on other sites More sharing options...
dsonesuk Posted April 1, 2017 Share Posted April 1, 2017 NOT! An id reference it must be unique within a page, only class name can be used multiple times within a page. Link to comment Share on other sites More sharing options...
Max Castril Posted April 2, 2017 Author Share Posted April 2, 2017 Thanks again dsoneuk. Seems a strange rule to have, to me. It works live as well. I have utterly NO IDEA how to resolve this. Link to comment Share on other sites More sharing options...
davej Posted April 2, 2017 Share Posted April 2, 2017 Why do you think your anchor tag needs the same id as something else? Link to comment Share on other sites More sharing options...
Max Castril Posted April 3, 2017 Author Share Posted April 3, 2017 I just want to apply some CSS to certain anchors and nothing else. I suppose I could use <a style = "width:.....etc.... ...or would <a class = "area1" href.....etc> ????? Link to comment Share on other sites More sharing options...
Ingolme Posted April 3, 2017 Share Posted April 3, 2017 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 More sharing options...
Max Castril Posted April 4, 2017 Author Share Posted April 4, 2017 Many thanks for everyone's help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now