| Learn | HTML - Classes and IDs - Giving an element a class |
|---|
| Giving an element a class Classes are identifiers for the elements that they are assigned to. Use the To assign multiple classes to an element, separate the class names with spaces. Using classes in CSSClasses can be used for styling certain elements without changing all elements of that kind. For example, these two Classes of the same name can be given to any number of elements on a page and they will all receive the styling associated with that class. This will always be true unless you specify the element within the CSS. For example, we have two elements, both with the class If our CSS is as below, then the color green will be applied to the text within both elements: However, if we only want to target Nevertheless, when styling with CSS, it is generally recommended that only classes (e.g. As with any other selector, classes can can be nested: You can also chain the class selector to only select elements that have a combination of several classes. For example, if this is our HTML: And we want to colour this specific piece of text pink, we can do the following in our CSS: |
Read Article
https://develop.horje.com/learn/1434/reference