Billa Billa - 1 year ago 105
CSS Question

Can I use DIV class and ID together in CSS?

Can I use DIV Class and ID together in CSS?
For example:

<div class="x" id="y">

Answer Source

Yes, yes you can.

#y.x {
 /* will select element of id="y" that also has class="x" */


.x#y {
 /* will select elements of class="x" that also have an id="y" */

Incidentally this might be useful in some use cases (wherein classes are used to represent some form of event or interaction), but for the most part it's not necessarily that useful, since ids are unique in the document anyway. But if you're using classes for user-interaction then it can be useful to know.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download