Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Linking CSS to an HTML Document | Getting Started with CSS
CSS Fundamentals

bookLinking CSS to an HTML Document

Unveiling the Three Paths of CSS

The visual appearance of a webpage relies on the synergy between HTML and CSS. These technologies work in three distinct ways to style content: inline styles, embedded style sheets, and external style sheets. Let's explore each approach, highlighting their strengths and limitations.

Inline Styles

Inline styles apply CSS directly to an element via the style attribute. They are quick to use but not reusable.

index.html

index.html

copy

Here, color: blueviolet affects only this specific <p> element.

Embedded Style Sheet

An embedded style sheet is placed inside the <head> of an HTML document using <style> tags. It styles the current page only.

index.html

index.html

copy

All <p> elements on this page receive the defined color and font size.

External Style Sheet

External CSS is the most scalable and preferred method. You store styles in a separate .css file and link it using <link> in the <head>.

index.html

index.html

styles.css

styles.css

copy

The external file contains reusable rules for the entire project. The rel="stylesheet" attribute indicates that this link loads a CSS file.

Note
Summary

Inline styles: quick, but not reusable.

Embedded style sheet: useful for single-page styling

External style sheet: best for larger or multi-page projects

question mark

What ways of adding styles to the HTML document exist?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

bookLinking CSS to an HTML Document

Swipe to show menu

Unveiling the Three Paths of CSS

The visual appearance of a webpage relies on the synergy between HTML and CSS. These technologies work in three distinct ways to style content: inline styles, embedded style sheets, and external style sheets. Let's explore each approach, highlighting their strengths and limitations.

Inline Styles

Inline styles apply CSS directly to an element via the style attribute. They are quick to use but not reusable.

index.html

index.html

copy

Here, color: blueviolet affects only this specific <p> element.

Embedded Style Sheet

An embedded style sheet is placed inside the <head> of an HTML document using <style> tags. It styles the current page only.

index.html

index.html

copy

All <p> elements on this page receive the defined color and font size.

External Style Sheet

External CSS is the most scalable and preferred method. You store styles in a separate .css file and link it using <link> in the <head>.

index.html

index.html

styles.css

styles.css

copy

The external file contains reusable rules for the entire project. The rel="stylesheet" attribute indicates that this link loads a CSS file.

Note
Summary

Inline styles: quick, but not reusable.

Embedded style sheet: useful for single-page styling

External style sheet: best for larger or multi-page projects

question mark

What ways of adding styles to the HTML document exist?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 2
some-alt