html and css

Even better than integrating CSS into an HTML5 tag, you can define your CSS properties in a CSS file — this is what we recommend the most.

This will make your code much more readable and much more maintainable over time.

The reason is that on one side you will have your CSS files, and on the other side your HTML files. And elsewhere, you will have your JavaScript files. We (strongly) recommend using one or more separate CSS files.

Then, to include them in your HTML document, simply use the <link> tag with the attributes rel="stylesheet", type="text/css", and href which is the link to your CSS file, whether it is hosted on your site or on another website — you provide the URL to your style.css.

Example:

<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="myFile.css"/>
…
</head>

…
</html>

In the myCssFile.css file, you directly put the CSS code you need. The format is exactly like what we have seen throughout this article series:

body {
   font-size: 12px;
   font-family: Arial;
}

The <link> tag

As we just saw, the <link> tag allows, among other things, to apply formatting to a given document from an external stylesheet. When a number of HTML documents use the same stylesheet, you can simply modify the layout of all documents through a single file.

Let’s take this CSS code as an example and place it in a demo.css file:

/* demo.css */
 body {
     background:white;
     color:blue;
 }

Every time you need to apply this style to a document, you simply call the demo.css file using the <link> tag:

<!DOCTYPE html>
<html>
<head>
    <title>La fameuse page « Hello World »</title>

    <link rel="stylesheet" href="demo.css">

</head>
  <body>
    <p>Hello world!</p>
  </body>
</html>

Every page that calls the demo.css file via the <link> tag will then benefit from the styles contained in the CSS file. This not only reduces the size of HTML files, but the caching system (web server, proxy servers, and browser) will be able to read the demo.css file as many times as needed while loading it into memory only once. Performance will be greatly improved.

Recent Posts

Recent Comments

Itamde is also an online programming school.

Itamde

Learn what you want, at your own pace

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You may also be interested in…

Artificial intelligence is reshaping every pixel

Artificial intelligence is reshaping every pixel

Just a few years ago, editing a photo meant spending hours working meticulously in Photoshop, mastering layers, masks and curves. In 2026, everything has shifted. AI photo editing tools no longer settle for automatic filters — they understand image content, anticipate...

The 10 Best Free AI Tools for Developers in 2026

The 10 Best Free AI Tools for Developers in 2026

Artificial intelligence is transforming how developers write, test, and deploy code. In 2026, many AI tools are freely accessible, offering capabilities that would have seemed impossible just a few years ago. Whether you're a beginner or experienced developer, these...

CSS colors

CSS colors

CSS colors can be defined in hexadecimal. Hexadecimal uses three components: red, green, and blue. You can define colors in shorthand hexadecimal: for example #DC2 corresponds to #DDCC22. Note that some colors cannot be abbreviated. The goal is to shorten your...

Stay up to date with the latest news and developments

Access restricted content

Discover behind-the-scenes details of our projects, exclusive resources, and the progress of our creations in real time.

Sign up for our newsletter

Receive our news, creative insights, and updates from the studio directly in your inbox.

Follow us

Join our community on social media to follow our daily projects and interact with us.