How to Use the Grouping Selectors in CSS With Examples
This Blog You Will Learn
ஃ What is Grouping Selectors in CSS
ஃ Syntax:
ஃ structure diagram examples
What is Grouping Selectors in CSS- Grouping Selectors CSS are used to apply the same styles to multiple element at once.
- Writing separate CSS for each element you can group them using commas.
- Grouping Selectors denoted by (,)
selector1, selector2, selector3
{
property1: value1;
property2: value2;
. . .
. . .
. . .
}
Why Use Grouping Selectors ?
- Avoid repetition
- keep css clean and organized.
- improves readability
- Save time
ஃ structure diagram examples
How to Use the Grouping Selectors in CSS With Examples
Example
<html>
<head>
<title> Grouping Selectors in CSS </title>
<style>
#intro,.demo{
border: 5px inset gold;
color:dodgerblue;
text-align:center;
}
</style>
</head>
<body>
<div class="demo">
<h1> Grouping Selectors in CSS </h1>
<P> learn programming language css </P>
</div>
<p id ="intro">
</body>
</html>
How to Use the Grouping Selectors in CSS With Examples
Explain Program
Step 1] <!DOCTYPE html>
- This declare the document type.
- browser that the document is written in html
Step 2]
<html>.... .
- html is the root element of the html page.
- Every thing inside it is part of the webpage.
Step 3]
text tag text appears on the browser tab.
<head>
<title> Grouping Selectors in CSS </title>
Step 4]
<style>
#intro,.demo{
border: 5px inset gold;
color:dodgerblue;
text-align:center;
}
</style>
CSS grouping selector that style two selectors together.
# intro
.demo
Styles Apllied ( two element )
- border: 5px inset gold;
- color:dodgerblue;
- text-align:center;
Step 5]
closing the Tag
Step 6]
<body> Section
<body>
<div class="demo">
<h1> Grouping Selectors in CSS </h1>
<P> learn programming language css </P>
</div>
<p id ="intro">
<div class="demo">
- <h1> → Main heading
- <p> → Paragraph text
<p id="intro">
- Paragraph id Selector
- Styled by #intro
- URL show website
Step 7]
closing the Tag
How to Use the Grouping Selectors in CSS With Examples
Output
Related Post :-
Comments
Post a Comment