Resources | Subject Notes | Information Communication Technology ICT | Lesson Plan
Cascading Style Sheets (CSS) are used to control the presentation of HTML elements. Saving styles as a separate CSS file offers several advantages, including reusability, maintainability, and cleaner HTML code.
To save styles in a CSS file, you need to create a new text document and save it with a .css extension (e.g., style.css).
Inside the CSS file, you define styles using rules. Each rule consists of a selector (the HTML element you want to style) and a declaration block (containing one or more property-value pairs).
Example:
body { font-family: Arial, sans-serif; background-color: #f0f0f0; } h1 { color: blue; text-align: center; } p { font-size: 16px; line-height: 1.5; }
To apply the styles defined in the CSS file to your HTML document, you need to link the CSS file using the element in the
section of your HTML.
Example:
Website Authoring - CSS Styles This is a Heading
This is a paragraph of text. It will be styled according to the rules defined in the style.css file.
Name | Age |
---|---|
John Doe | 30 |
Jane Smith | 25 |
Saving styles in a CSS file is a fundamental practice in website authoring. It promotes organization, efficiency, and maintainability of your web projects.