7 Css Selectors Every Developer Shuld Know About
7 CSS Selectors Every Developer Shuld Know About 7 CSS Selectors
7 Css Selectors Every Developer Shuld Know About
- 2. #ID SELECTOR
1. ELEMENT OR GROUP SELECTOR
Element selector allows you to select and give styling to all elements with the same specified element name. If there are multiple elements with the same style definitions, you can group all the elements and apply styling to all of them together.
2. #ID SELECTOR
Using the # symbol followed by id name allows you to target by id and apply styling to all specified elements with a selected id. Using this selector sounds good because of its simplicity but keep in mind that id should be unique for the entire web page. It means you are not allowed to assign an id selector for multiple elements.
3. ATTRIBUTE SELECTOR
Using attribute selector, you can select all elements by the name or value of a given attribute and apply styling to them.
Below is an example of an HTML line which has 'rel' attribute with the value of "newfriend"
4. DESCENDANT SELECTOR
Descendant selector apply styling to only those elements that are descendants of a specified element. This selector is very useful when you need to apply styling only for some specific elements.
5. THE STAR SELECTOR
It is also called as universal selector (*) and it selects everything in the document and apply styling to them. By default your browser already defines the styling to the element and when you want to reset the browser default styles you can use star selector.
6. NTH-OF-TYPE AND NTH-CHILD
Basically :nth-of-type selector allows you to select every element that is a specified nth child of a specified type of it parent. n can be any number, keyword, or formula that will specify the position of an element among a group of siblings.