How to Include CSS in HTML?

Admin
0

There are 3 main ways to include CSS in HTML:

1. Inline CSS: Add CSS directly to an HTML element using the style attribute

Inline CSS Example:

<p style="color: blue; font-size: 18px;">Welcome to W3Studies</p>

Try It yourself

2. Internal CSS: Place CSS within a <styletag inside the <head> section of your HTML file. This method is useful for applying styles to a single HTML page.

Internal CSS Example:

<head>
    <style>
        p {
            color: blue;
            font-size: 18px;
        }
    </style>
</head>

Try It yourself

3. External CSS: Link to an external CSS file (e.g., styles.css) using the <link> tag in the <head> section. This is ideal for larger projects, as you can style multiple pages with one CSS file.

External CSS Example:

<head>
   <link rel="stylesheet" href="styles.css">
</head>

Try It yourself


Basic CSS Example

Post a Comment

0Comments
Post a Comment (0)