Why ID is still working for multiple elements as well?


Replace this line with your code. 
 whats the differnce between id and class then if ID can be used for multiple elements?
<!DOCTYPE html>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<!--Add your HTML elements with the ID "serious" below!-->
		<p id="serious">yoyi</p>
		<h5 id="serious"> i am rare</h5>

CSS code

/*Define your CSS id #serious below!*/


unfortunately browsers today allow you to use the same id name multiply times. Bad practice. If an element has both an id and class, the id property's get applied (if both id and class for example have a color property, the color of id gets applied)

Also, when using jquery only one elements work with id, where multiply work with classes, so it is still important


So you are saying that because of browsers , id is can be applied for multiple elements but usually it doesnt work that way right, in jQuery id is applicable only once right?


yes, exactly what i am saying. I problems with some jquery code because i was so stupid to use a id instead of an element while i had multiply with the same name.

So, use id's only once per page, for important things, and classes for the rest.


what about the first sentence that I wrote ?about the browsers thing? thanks for you reply means a lot!


well, long time ago browser didn't support using the same id name multiply times, which causes problem loading the webpage. Today this changed, but because of the stronger css for id's and so on, i would still follow w3c recommendations to use id's only once.


thank you for your reply and time!