CSS Introduction
The full form of CSS is Cascading Style Sheet. CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
Why Use CSS?
CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.CSS Rule Structure (Syntax)
selector{
property : value;
}
property : value;
}
Example:
body{
background:#ff00ff; }
Output:
CSS Selectors:
There are three ways we can provide CSS selectors.
1. HTML element selectors or HTML tags.
2. Class selectors using dot (.) symbol
3. ID selectors using hash (#) symbol
color:#ff00ff;
}
h1{
text-align:center;
}
You can give the above code as follows :
h1{
color:#ff00ff;
text-align:center;
}
Example:
h1{
color:red;
}
h2{
color:red;
}
You can give the above code as follows :
h1 , h2{
color:red;
}
Grouping Selectors:
There are two ways we can group selectors and give property for the selectors.1)Same selector:
Providing css property and values for same selector of html element via line by line process.Example:
h1{color:#ff00ff;
}
h1{
text-align:center;
}
You can give the above code as follows :
h1{
color:#ff00ff;
text-align:center;
}
2)Different selectors:
Giving same css property and values for various html element is separated it by commas and execute it in output.Example:
h1{
color:red;
}
h2{
color:red;
}
You can give the above code as follows :
h1 , h2{
color:red;
}
No comments:
Write comments