More curiosity than a real problem, but...
I've been abusing HTML ID attributes slightly.
..box {
margin: 10px;
}
#red {
background-color: #ff0000;
}
#green {
background-color: #00ff00;
}
<div class="box" id="red"></div>
<div class="box" id="green"></div>
<div class="box" id="red"></div>
To get a red box followed by a green box and another red box.
HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.
What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.
I've been abusing HTML ID attributes slightly.
..box {
margin: 10px;
}
#red {
background-color: #ff0000;
}
#green {
background-color: #00ff00;
}
<div class="box" id="red"></div>
<div class="box" id="green"></div>
<div class="box" id="red"></div>
To get a red box followed by a green box and another red box.
HTML validators complain because id attributes are supposed to be unique,
but the big three browser engines let me get away with it.
What's the "right" way to do this? Should I just have boxred and boxgreen
classes? That seems a little wasteful when I only want to change one
property.
Comment