Introduction to CSS
Cascading Style Sheets, commonly known as CSS, is a stylesheet language used for the presentation of web pages, including colors, layout, and fonts. Together with HTML and JavaScript, CSS forms the core building blocks of web development. Understanding CSS is crucial to creating visually appealing and user-friendly websites.
History of CSS
CSS was developed by Håkon Wium Lie and Bert Bos in 1996. It was created to separate content from presentation, allowing easier maintenance and consistent styling.
How CSS Works
CSS works by associating styles with elements of HTML documents. When a web browser navigates to a webpage, it reads the HTML to find the structure of the page, and then applies the CSS rules to style the page accordingly.
Basic Syntax of CSS
The basic syntax of CSS consists of selectors and declaration blocks:
- Selector: This determines which HTML elements the styles will apply to.
- Declaration Block: This contains one or more declarations, each consisting of a property and a value. For example:
body { background-color: blue; }
Types of CSS
- Inline CSS: Styles defined directly within an HTML element using the “style” attribute.
- Internal CSS: Styles defined within a