How do I select a class like class="boolean optional"
?
I have tried this:
.boolean optional {CSS} .boolean_optional {CSS}
They are called multiple class selectors. You basically just need to make sure all the class names are connected (no spaces between them) and separated with a dot. Show activity on this post. Classes will never actually have spaces in their name.
The class name can't contain a space, but it can contain hyphens or underscores. Any tag can have multiple space-separated class names.
A class name can't have spaces. When you have a space-separated string in your class attribute, you're always giving your element several classes.
You simply can't have spaces. If you use a space it means you're using two different classes.
As Zepplock says, that's actually two classes in a single attribute: boolean
and optional
. The space is not part of a class name; it acts as the separator.
These three selectors will all match it:
.boolean .optional .boolean.optional
The last selector only picks up this element as it has both classes.
You never include a space when chaining class selectors, not even like this:
.boolean .optional
As that selects .optional
elements that are contained within separate .boolean
elements.
Those are not classes with spaces :) They are called multiple class selectors.
You basically just need to make sure all the class names are connected (no spaces between them) and separated with a dot.
.boolean.optional { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With