CSS Syntax
- CSS (Cascading Style Sheets) is a language used to style a web page.
- CSS syntax consists of a selector and a declaration block.
- The selector specifies which HTML element the style should be applied to.
- The declaration block contains one or more declarations, separated by semicolons.
- Each declaration consists of a property and a value, separated by a colon.
CSS Selector
The CSS selector is used to select the HTML element that you want to style. There are several types of selectors, including element selectors, class selectors, and ID selectors.
Here are some examples of CSS selectors:
- Element Selector:
p
- selects all<p>
elements on the page. - Class Selector:
.my-class
- selects all elements with the classmy-class
. - ID Selector:
#my-id
- selects the element with the IDmy-id
.
CSS Declaration Block******** The CSS declaration block contains one or more declarations, separated by semicolons.
Each declaration consists of a property and a value, separated by a colon.