- CSS stands for Cascading Style Sheets
- CSS describes how HTML elements are to be displayed on screen, paper, or in other media
- CSS saves a lot of work. It can control the layout of multiple web pages all at once
- External stylesheets are stored in CSS files
The selector points to the HTML element you want to style.
The declaration block contains one or more declarations separated by semicolons.
Each declaration includes a CSS property name and a value, separated by a colon.
Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded by curly braces.
- p is a selector in CSS (it points to the HTML element you want to style:). >
- color is a property, and red is the property value
- text-align is a property, and center is the property value
A CSS selector selects the HTML element(s) you want to style.
CSS selectors are used to "find" (or select) the HTML elements you want to style.
We can divide CSS selectors into five categories:Simple selectors (select elements based on name, id, class), Combinator selectors (select elements based on a specific relationship between them), Pseudo-class selectors (select elements based on a certain state), Pseudo-elements selectors (select and style a part of an element), Attribute selectors (select elements based on an attribute or attribute value),
p {
text-align: center;
color: red;
}
#para1 {
text-align: center;
color: red;
}
.center {
text-align: center;
color: red;
}
This paragraph refers to two classes.
* {
text-align: center;
color: blue;
}
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p {
text-align: center;
color: red;
}
Comments are used to explain the code, and may help when you edit the source code at a later date. Comments are ignored by browsers.
The CSS border properties allow you to specify the style, width, and color of an element's border. The border-style
property specifies what kind of border to display
we can have many types of borders including border-width, Border-Color, Border-sides, Border-Shorthand, Rounded Borders
The CSS margin properties are used to create space around elements, outside of any defined borders. With CSS, you have full control over the margins. There are properties for setting the margin for each side of an element (top, right, bottom, and left).