What are Selectors & Types of selectors in HTML?
Selector defines HTML element to be styled. Selectors can contains more than one HTML elements. The Selectors in CSS have four type:
• ID selector:
ID Selector is used to style specific element with a unique id. Id is represented by ‘#' in Style sheet. Id represents unique name to HTML element and created by using id attribute of HTML elements. Id selector is used as follows:
#nameofid{ property and value }
• Class selector:
Class selector is used to style multiple elements in a specific class. Class is represented by period (.) In style sheet. Class name can be created by using class attribute of HTML elements. Class selector is used as follows:
.nameofclass( Property and value )
• Group selector:
Group selector is used to style all elements in a group. With help of Group selectors we can apply same style of different elements without writing them multiple times. Group selector is used as follows:
E1, E2, E3 { Property and value }
• Universal selector:
Universal selector is used to style all elements inside HTML code. This type of selector will be useful for styling entire page with same style. Universal selector is represented by (*). Universal selector style all elements in HTML irrespective of their ID's And Classes
Comments in CSS can be written by /* ………. */. (They are not displayed)
Comments
Post a Comment