Using Inline, Internal, and External Techniques to Integrate CSS into HTML

Inline CSS : When you want to give a look, to one element in an HTML document you can use inline styles. These styles are applied directly within the elements style attribute.

Example of Inline CSS:

<p style="color: red; font-size: 20px;">This is a paragraph with inline CSS.</p>

Internal CSS : Internal styles, also called embedded CSS are defined inside the <style> tag within the <head> section of an HTML file. This approach is handy, for maintaining styles across a webpage.

Example of Internal CSS:

<head>
    <style>
        body {
            background-color: lightblue;
        }
        h1 {
            color: navy;
        }
    </style>
</head>
<body>
    <h1>Welcome to My Site</h1>
    <p>Body text styled with internal CSS.</p>
</body>

External CSS : On the hand external styles are stored in a CSS file and linked to the HTML document using the <link> tag. This method works best when you need to apply the styles across pages on a website.

Example of External CSS:

<head>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Heading Styled from External CSS</h1>
    <p>Paragraph styled from the external CSS file.</p>
</body>

And this is what styles.css would contain

h1 {
    color: darkgreen;
}
p {
    color: darkblue;
}

 

 

logo

CSS

Using Inline, Internal, and External Techniques to Integrate CSS into HTML

Beginner 5 Hours

Inline CSS : When you want to give a look, to one element in an HTML document you can use inline styles. These styles are applied directly within the elements style attribute.

Example of Inline CSS:

<p style="color: red; font-size: 20px;">This is a paragraph with inline CSS.</p>

Internal CSS : Internal styles, also called embedded CSS are defined inside the <style> tag within the <head> section of an HTML file. This approach is handy, for maintaining styles across a webpage.

Example of Internal CSS:

<head>
    <style>
        body {
            background-color: lightblue;
        }
        h1 {
            color: navy;
        }
    </style>
</head>
<body>
    <h1>Welcome to My Site</h1>
    <p>Body text styled with internal CSS.</p>
</body>

External CSS : On the hand external styles are stored in a CSS file and linked to the HTML document using the <link> tag. This method works best when you need to apply the styles across pages on a website.

Example of External CSS:

<head>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>Heading Styled from External CSS</h1>
    <p>Paragraph styled from the external CSS file.</p>
</body>

And this is what styles.css would contain

h1 {
    color: darkgreen;
}
p {
    color: darkblue;
}

 

 

Similar Data Science Tutorials

Related tutotials

Frequently Asked Questions for css

line

Copyrights © 2024 letsupdateskills All rights reserved