What is CSS?
CSS (Cascading Style Sheets) is a stylesheet language used for describing the presentation of a document written in HTML or XML. It controls the layout of multiple web pages all at once, making it a powerful tool for web developers.
Why Use CSS?
- Separation of Content and Style: Keeps HTML clean and makes it easier to maintain.
- Consistency: Ensures a consistent look across multiple pages.
- Efficiency: Reduces code repetition and speeds up website maintenance.
- Accessibility: Improves accessibility for users with disabilities.
Basic Structure of CSS
CSS is made up of rules that include selectors and declarations:
- Selector: Indicates the HTML element you want to style.
- Declaration: Contains property and value pairs.
Example:
body { background-color: lightgreen; }
In this example, body
is the selector, and background-color: lightblue;
is the declaration.
Learning Objectives
- Understand the purpose and benefits of CSS.
- Learn how to apply basic CSS rules to HTML elements.
- Explore different ways to add CSS to a webpage (inline, internal, and external stylesheets).