Introduction to CSS
-
CSS stands for Cascading Style Sheets.
-
CSS is used to style and design HTML elements, enhancing the look and feel of web pages.
-
CSS was developed by HÃ¥kon Wium Lie, the Chief Technical Officer (CTO) at Opera Software.
-
It was initially proposed in 1994 and officially published in 1996.
-
The current version of CSS is CSS3, which introduced numerous new features and capabilities to web design.
CSS Syntax
The syntax of CSS consists of a selector and a declaration block. A typical CSS rule looks like this:
selector {
property: value;
}
For example:
h1 {
color: blue;
}
This CSS rule will turn all <h1>
elements blue.
Cascading
Cascading refers to the order in which CSS rules are applied to elements. CSS follows a set of rules to determine which styles to apply when multiple rules target the same element. The key factors in cascading are:
- Specificity: More specific selectors override more general ones. For example, an ID selector is more specific than a class selector.
- Priority: When two rules have the same specificity, the one defined later in the stylesheet takes priority.
Note: CSS code is written in a key-value pair format. The key represents the property, and the value defines the style applied to the selected element.
- Style: CSS rules used to apply styles to elements on a webpage.
- Sheet: A digital document containing CSS rules, typically linked to an HTML document.