Summary 3

Intro to CSS

CSS, short for Cascading Style Sheets, is a language used to style web pages. It defines how HTML elements are displayed on the screen, saving a lot of extra work compared to inline CSS. CSS is essential for defining styles on your web pages, including design, layout, and variations in display for different devices and screen sizes. Since HTML was never intended to include formatting tags, CSS greatly reduces the need for manual formatting.

CSS in relation to HTML elements

CSS operates through selectors, which point to the HTML elements you want to style. A declaration block contains one or more declarations separated by semicolons. Each declaration consists of a CSS property name and its value, separated by a colon. Multiple declarations are separated by semicolons, and declaration blocks are enclosed in curly brackets.

CSS selectors

CSS selectors are used to target the HTML elements you wish to style. CSS can be divided into five main categories of selectors:

• Simple Selectors – select elements based on name, class, or ID
• Combinator Selectors – select elements based on a specific relationship between them
• Pseudo-class selectors – select elements based on a certain state
• Pseudo-element selectors – select and style a part of an element
• Attribute selectors – select elements based on attributes or attribute values.