CSS introduction:
- CSS stands for Cascading Style Sheet.
- CSS describes how HTML elements are to be displayed on screen.
- CSS saves a lot of work. It can control the layout of multiple web pages all at once.
- CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.
- A CSS rule-set consists of a selector and a declaration block.
- 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.
- A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly braces.
- External style sheet:
- If we write a style sheet in a separate file with extension .css then it is called as external style sheet.
- With an external style sheet, you can change the look of an entire website by changing just one file.
- Each page must include a reference to the external style sheet file inside the link element. The link element goes inside the head section:
- Internal style sheet
- An internal style sheet may be used if one single page has a unique style.
- Internal styles are defined within the style element, inside the head section.
- Inline style
- An inline style may be used to apply unique style for a single element.
- To use inline style, add the style attribute to the relevant element. The style attribute can contain any CSS property.