Is it bad practice to style an element using its id or should I be style every element referencing the appropriate css ?
<div id="test">
</div>
versus :
<div id="test" class="testClass">
</div>
#test{
color:blue;
}
.testClass {
color:blue
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not a bad or good practice. The purpose of the
idselector differs fromclass.If you’re planning to style this one element only and not re-use the styles anywhere else –
idis you choice. If you need a lot of similardiv-s to have the same style – useclass