Reputation: 42957
an HTML element can have more than a CSS class?
If it is possible how can I set 2 classes on a h1?
For example I am trying to set 2 classes (text-center and title) on this element but in this way can't work:
<h1 class="text-center, title"><small>TEXT TEXT TEXT</h1>
Tnx
Upvotes: 1
Views: 50
Reputation: 201538
An HTML element can have any number of classes. In a class
attribute, the class names are separated by spaces or, generally, by sequences of whitespace characters. This is not a CSS issue at all. There are no “CSS classes”; CSS has just class selectors (which refer to elements by their classes as set in HTML).
Example:
<h1 class="text-center title">
However, in this case, the class names suggest that you should design the coding differently. Class names work best when they reflect intended structual or semantic role rather than specific rendering details. It is quite possible that you could use just one class here, or no classes: a page normally has just one h1
element, so you can style it using the h1
selector.
Upvotes: 1
Reputation: 4266
Just add a space, eg:
<h1 class="text-center title"><small>TEXT TEXT TEXT</h1>
Upvotes: 4