CSS Selectors
Used to target and apply styles to specific HTML elements on a web page.
CSS selectors allow you to define rules that determine which elements should receive a particular style.
THere are 4 selectors use din css
CSS selectors allow you to define rules that determine which elements should receive a particular style.
THere are 4 selectors use din css
- Universal Selector (*)
- Type Selector
- Class Selector (.classname)
- ID Selector (#idname)
Example
/* Target all paragraphs inside a div with class "content" */
div.content p {
margin: 10px;
color: green;
}
Universal Selector (*)
Targets all elements on the page.
Rarely used due to its broad scope.
Syntax: * { margin: 0; padding: 0; }
Rarely used due to its broad scope.
Syntax: * { margin: 0; padding: 0; }
Type Selector
Targets elements of a specific HTML tag.
Syntax: p { font-size: 16px; }
Syntax: p { font-size: 16px; }
Class Selector (.classname)
Targets elements with a specific class attribute.
Class names start with a dot (.) followed by the class name.
Syntax: .highlight { background-color: yellow; }
Class names start with a dot (.) followed by the class name.
Syntax: .highlight { background-color: yellow; }
ID Selector (#idname)
Targets a single element with a specific ID attribute.
ID names start with a hash (#) followed by the ID name.
Should be unique within the page.
Syntax: #header { color: blue; }
ID names start with a hash (#) followed by the ID name.
Should be unique within the page.
Syntax: #header { color: blue; }
Quick Recap
Topics Covered
Element
Description
Example
Practice With Examples in Compilers
The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compile or Try on own Now
Example 1
Example 1
Example 2
Example 3
Example 4
Example 5