Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Connecting HTML and CSS | Introduction to CSS
CSS Fundamentals

Connecting HTML and CSSConnecting HTML and CSS

Unveiling the Three Paths

When it comes to designing a website, the visual appearance of a webpage is primarily influenced by two technologies - HTML and CSS. These two technologies work together in three distinct ways: inline styles, embedded style sheets, and external style sheets. Let's unravel the artistry behind these methods, exploring their strengths and weaknesses.

Inline Styles

Inline styles introduce CSS directly to an HTML element using the style attribute. These styles are convenient when dynamic changes are needed – a realm where JavaScript often wields its magic. However, the drawback is their limited scope; they can't be easily extended or reused across different elements.

For example, let's apply an inline style to change the text color to blueviolet.

html

index.html

css

index.css

js

index.js

Embedded Style Sheet

The embedded style sheet resides within an HTML document's <head>, encapsulated within <style> tags. This method allows us to tailor styles specifically to a single page. However, it lacks the versatility needed to be shared across multiple pages.

html

index.html

css

index.css

js

index.js

External Style Sheet

The external style sheet emerges as the grand maestro of CSS management. By employing the <link> tag within the <head> of an HTML document, this technique offers scalability, maintainability, and reusability – qualities coveted in web projects.

But how does it work? We create a file with the css extension and reference it in our HTML document. Below is a glimpse of both files, index.html and index.css.

html

index.html

css

index.css

js

index.js

The rel attribute stands for "relationship". rel="stylesheet" denotes how the index.css is related to the index.html.

Note

Remember that while inline styles cater to a single element, styles from an External Style Sheet or an Embedded Style Sheet can adorn multiple elements, streamlining your design efforts.

question-icon

What ways of adding styles to the HTML document exist?

Selecione algumas respostas corretas

Tudo estava claro?

Seção 1. Capítulo 2

Connecting HTML and CSSConnecting HTML and CSS

Unveiling the Three Paths

When it comes to designing a website, the visual appearance of a webpage is primarily influenced by two technologies - HTML and CSS. These two technologies work together in three distinct ways: inline styles, embedded style sheets, and external style sheets. Let's unravel the artistry behind these methods, exploring their strengths and weaknesses.

Inline Styles

Inline styles introduce CSS directly to an HTML element using the style attribute. These styles are convenient when dynamic changes are needed – a realm where JavaScript often wields its magic. However, the drawback is their limited scope; they can't be easily extended or reused across different elements.

For example, let's apply an inline style to change the text color to blueviolet.

html

index.html

css

index.css

js

index.js

Embedded Style Sheet

The embedded style sheet resides within an HTML document's <head>, encapsulated within <style> tags. This method allows us to tailor styles specifically to a single page. However, it lacks the versatility needed to be shared across multiple pages.

html

index.html

css

index.css

js

index.js

External Style Sheet

The external style sheet emerges as the grand maestro of CSS management. By employing the <link> tag within the <head> of an HTML document, this technique offers scalability, maintainability, and reusability – qualities coveted in web projects.

But how does it work? We create a file with the css extension and reference it in our HTML document. Below is a glimpse of both files, index.html and index.css.

html

index.html

css

index.css

js

index.js

The rel attribute stands for "relationship". rel="stylesheet" denotes how the index.css is related to the index.html.

Note

Remember that while inline styles cater to a single element, styles from an External Style Sheet or an Embedded Style Sheet can adorn multiple elements, streamlining your design efforts.

question-icon

What ways of adding styles to the HTML document exist?

Selecione algumas respostas corretas

Tudo estava claro?

Seção 1. Capítulo 2
some-alt