Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Using External Resources | Working with Advanced Elements
HTML for Beginners

bookUsing External Resources

When you develop web pages with HTML, you often need to link to external resources. For example, we usually keep our CSS and JavaScript codes in separate files.

Adding external CSS files

Suppose your CSS codes are in an "index.css" file. You use the <link> tag to link that file to your HTML code. We place this <link> tag inside the <head> tag.

With the <link> tag, we use the rel attribute to define the relationship of the external file and the href attribute to assign the external file path.

Here is the code we use for that:

<link rel="stylesheet" href="index.css" />
index.html

index.html

index.css

index.css

copy

Adding external Javascript files

When we want to add external Javascript files to our HTML web page, we use the <script> tag with the src attribute.

<script src="index.js"></script>
index.html

index.html

index.js

index.js

copy
question mark

Which of the following attributes are required for tag?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Awesome!

Completion rate improved to 7.69

bookUsing External Resources

Stryg for at vise menuen

When you develop web pages with HTML, you often need to link to external resources. For example, we usually keep our CSS and JavaScript codes in separate files.

Adding external CSS files

Suppose your CSS codes are in an "index.css" file. You use the <link> tag to link that file to your HTML code. We place this <link> tag inside the <head> tag.

With the <link> tag, we use the rel attribute to define the relationship of the external file and the href attribute to assign the external file path.

Here is the code we use for that:

<link rel="stylesheet" href="index.css" />
index.html

index.html

index.css

index.css

copy

Adding external Javascript files

When we want to add external Javascript files to our HTML web page, we use the <script> tag with the src attribute.

<script src="index.js"></script>
index.html

index.html

index.js

index.js

copy
question mark

Which of the following attributes are required for tag?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 2
some-alt