Klassen in HTML und CSS Titelbild

The class attribute assigns an element to one or more classes. Classes are an HTML concept used to mark similar elements in the markup with the (not exclusive!) goal of addressing them with a class selector. However, they do not necessarily have to be similar elements. Multiple class names are separated by spaces.

 

 

 

HTML Syntax

 

<div class="sport">

 

Classes in CSS

 

A class in CSS is - simply put - a grouping of properties that is defined once and is generally used multiple times. Classes can be applied multiple times in CSS. IDs, on the other hand, can only be used once per page because they must always be uniquely identifiable. Classes and IDs must not be combined with each other in CSS. To create a class, a period (.), followed by a class name, must first be written. The CSS properties are then defined in curly braces {}:

 

.sport {background-color:gray; color: white;}

 

HTML example

 

 

Do you have any questions about this topic? Or do you need help designing your website from a professional web agency in Munich? Then feel free to contact us!