What is the difference between an ID selector and CLASS?
Printable View
What is the difference between an ID selector and CLASS?
The id selector is used to specify a style for a single, unique element.It uses id attribute of the HTML and is given by "#". The class selector is used to specify a style for a group of elements. It is bit different from the id selector, the class selector is most often used on several elements. It is given by "."
Actually these HTML elements are used to while designing of HTML web site.
What is the difference between an ID selector and CLASS?
Basically id use for call function for example onclick function when user click the button javascript event perform by using that id value, classes used for css style function.
ID should be used for large areas like wrapper, header, content, footer. It is unique.
The class is used when you want to consistently style multiple elements throughout the page/site. Use a class when you want to consistently style multiple elements throughout the page/site. Classes are useful when you have, or possibly will have in the future, more than one element that shares the same style.
ID used when you have a single element on the page that will take the style. Remember that IDs must be unique. Examples of ids are main-content, header, footer, or left-sidebar.
Nice, thanks for sharing such information.