Lecture

Ways to Include CSS

There are three main methods to apply the defined CSS code to an HTML document.


1. Using External CSS

This method involves creating a separate file for CSS code and linking that file to the HTML document.

Linking an External CSS File in HTML
<head> <link rel="stylesheet" type="text/css" href="styles.css" /> </head>

Write your style code in a separate file named styles.css and link it to the HTML document using the <link> tag.


2. Using Internal CSS

You can define styles using a <style> tag within the <head> section of the HTML document.

The CSS defined this way only applies to the specific HTML document.

Defining CSS Internally in HTML
<head> <style> body { background-color: lightblue; } </style> </head>

3. Using Inline CSS

This method applies styles directly to HTML elements.

The defined style only applies to the specified element.

Applying Style Directly to HTML Element
<p style="color:red;">This sentence is displayed in red.</p>

Which method to choose depends on various factors such as project requirements and ease of maintenance.


Follow the highlighted parts in the code to input them yourself.

Mission
0 / 1

What is the most appropriate option to fill in the blank?

Defining styles using the `<style>` tag in the `<head>` section of an HTML document is called CSS.
external
internal
inline
alternative

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

HTML
CSS
Loading...