Selectors in CSS
What are CSS Selectors?
- CSS selectors are used to select the HTML elements for styling.
- There are multiple types of selectors in CSS: element selector, group selector, id selector, class selector, etc.
- Today we will see only some basic selectors in CSS and other selectors we will learn in upcoming tutorials.
Element Selector:
Element selectors are used to targeting the HTML element by tag name and style them in our style sheet.
Example:
index.html
Syle.css
Group Selectors:
The name suggests group selectors are used to selecting multiple elements and applying the same style to them.
Example:
Id Selector
Id selectors are mainly used to target particular HTML element with the help of id and apply styles to them. The id of any HTML element should be unique. Hash (#) is used to target the particular element from the HTML document.
Example:
Class Selector
Class selectors are mainly used to target multiple HTML elements with their classes and apply styles to them. An HTML element can contain multiple classes and multiple elements can have the same class. (.) is used to target the multiple elements with the class from the HTML document.
Example:
Introduction to CSS Part-2 PDF Click here to download
Easy Pickup
- 1. CSS More Samples
- 2. CSS Malayalam Classes
- 3. CSS Malayalam Notes