ID and Class CSS Selectors
ID Selector
id selectors allow you to style an HTML element that has an id attribute, regardless of its position in the document tree. To select an element with a specific id, use a hash character, and then follow it with the id of the element.
Syntax:-
Its syntax is:-
< style >
#element{
property: value;
}
< /style >
CLASS Selector
Class selectors work in a similar way to ID selectors. Classes can be used as many as we want while ids can only be used once. To select elements with a specific class for styling purposes, use a dot character, followed by the name of the class.
Syntax:-
Its syntax is:-
< style >
.element{
property: value;
}
< /style >