HTML class Attribute
- Class attribute is used to give class name to any element to group element together and apply CSS and JavaScript.
Syntax:
class=“class-name”
Note: You can use multiple class names for one element
Example:
π Try it yourself! Click the button below to run the code and see the output in action.
HTML Code
Output
- you can reuse class names if you want to repeat any functionality and style to other elements.
Example:

π Try it yourself! Click the button below to run the code and see the output in action.
HTML Code
Output
Note: The class name is case sensitive!
The Syntax For Class
- To create a class; write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {}
Example:

π Try it yourself! Click the button below to run the code and see the output in action.
HTML Code
Output
Output:
Designwithrehana
If you are interested in frontend development, you are at the right place.