Grade 11 Web Design: Introduction to CSS
1. What is CSS?
CSS stands for Cascading Style Sheets. It is used to style and design HTML elements.
2. Three Ways to Insert CSS into HTML:
- Inline CSS: inside a tag using the "style" attribute
Example: <p style="color: red;">This is red text</p>
- Internal CSS: inside a <style> tag in the <head> section
Example:
<style>
p { color: blue; }
</style>
- External CSS: in a separate .css file, linked using <link>
Example:
<link rel="stylesheet" href="styles.css">
3. Basic CSS Syntax:
selector { property: value; }
Example: h1 { color: green; font-size: 20px; }
4. Common CSS Properties:
- color: sets text color
- background-color: sets background color
- font-size: sets size of the font
- text-align: aligns text (left, center, right)
- margin: space outside an element
- padding: space inside an element