Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Including CSS: External Styles | Basic Introduction
Introduction to CSS Part I
course content

Kurssisisältö

Introduction to CSS Part I

Introduction to CSS Part I

1. Basic Introduction
2. Selectors and Cascade
3. Box Model

book
Including CSS: External Styles

To include an external CSS file in an HTML document, you can use the <link> element. This element should be placed in the HTML document's <head> section. The <link> element should have a rel attribute with a value of stylesheet to indicate that the linked file is a stylesheet and a href attribute with the URL of the external CSS file.

css

index.css

html

index.html

copy

Advantages:

  • External CSS files can be cached by the browser, which means the browser doesn't have to download the stylesheet every time the user visits a page on your website. This can improve the performance of your website;

  • It allows you to separate the styling information from the content of your HTML document;

  • These files can be shared among multiple HTML documents.

Disadvantages:

  • This can slow down the loading time of your website, especially if you have many external CSS files;

  • Another potential drawback is that keeping track of all the external CSS files you're using on your website can be challenging.

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3

Kysy tekoälyä

expand
ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

course content

Kurssisisältö

Introduction to CSS Part I

Introduction to CSS Part I

1. Basic Introduction
2. Selectors and Cascade
3. Box Model

book
Including CSS: External Styles

To include an external CSS file in an HTML document, you can use the <link> element. This element should be placed in the HTML document's <head> section. The <link> element should have a rel attribute with a value of stylesheet to indicate that the linked file is a stylesheet and a href attribute with the URL of the external CSS file.

css

index.css

html

index.html

copy

Advantages:

  • External CSS files can be cached by the browser, which means the browser doesn't have to download the stylesheet every time the user visits a page on your website. This can improve the performance of your website;

  • It allows you to separate the styling information from the content of your HTML document;

  • These files can be shared among multiple HTML documents.

Disadvantages:

  • This can slow down the loading time of your website, especially if you have many external CSS files;

  • Another potential drawback is that keeping track of all the external CSS files you're using on your website can be challenging.

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt