Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In CSS, is ".class1.class2" legal and common usage?

I am quite used to seeing

div.class1

and

#someId.class1

but what about

.class1.class2

? And I think it is identical to

.class2.class1

? Because there was an element with id someId but now we have two elements of this type showing on the page, so I want to add a class and use the class instead of id, therefore the .class1.class2 instead of #someId.class1

like image 848
nonopolarity Avatar asked Jun 18 '10 22:06

nonopolarity


People also ask

Does order of classes in CSS matter?

The Order of CSS Classes in HTML Doesn't Matter.

Does class name matter in CSS?

CSS class name never affects any factor of SEO. Because a class name is only to identify a particular section of designing. The class name can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name. Save this answer.

What does .class .class mean in CSS?

The .class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.

How do I use multiple classes in CSS?

To specify multiple classes, separate the class names with a space, e.g. <span class="left important">. This allows you to combine several CSS classes for one HTML element.


2 Answers

It will select items with both classes. So not items with either one.

<span class="class1 class2"></span>
like image 110
Jouke van der Maas Avatar answered Nov 15 '22 19:11

Jouke van der Maas


Yes, it is both legal and common. In the element, you would have something like this:

<div class="class1 class2">Hello</div>
like image 38
tylerl Avatar answered Nov 15 '22 19:11

tylerl