That’s what I thought too. :-/
Generally if you have an ID it’s for CSS use. IDs and Classes are for styling purposes and have no semantic value, per se.
Agreed.
I dont know what you mean by “ID and CLASS using the same value?”
<input id="email" name="email" class="email" type="text" />
so here is a shot gun answer:
the ID “it” and class “it” for example… are read as completely different things by the browser. They are declared separately as well as such:
#it{…css} /the ID/
.it{…css}/the Classs/
It is redundant if you have the same declaration for both… for example:
#it{color:red} /the ID/
.it{color:red}/the Classs/
it’s important , however to take note of specificity. ofr example… given ONLY the following rules:
#it{color:yellow} /the ID/
.it{color:red}/the Classs/
.other{color:green}
<p id=“it” class=“it”>hello world</p>
the text will appear in yellow. Yes , even tho the class declaration came after the ID in the css? why… because IDs have a higher specificity value than tags or classes.
Okay.
That is interesting.
I guess I just meant, “Why have an ID and CLASS with the same name?”
Also, “Why have an ID and a CLASS with the same name when you aren’t using both?”
if you had simply used <p class=“it green”>hello world</p> (no ID, but two classes} the last class in the order of the CSS would be the dominant one.
In essence, IF you created a class with general declarations and wanted to make some tweaks to a UNIQUE ELEMENT that was part of that class you can easily do so by using an ID is a good way to make tweaks.
Okay.
Incidentally, this is all from the point of CSS. IDs also serve to identify a specific element for js using: “GetElementById”. So sometimes an ID is simply there not for styling, but to help js find the element.
Okay.
TomTees