Home > database >  Best practice for `<link>` vs. `<style>` in head and in section
Best practice for `<link>` vs. `<style>` in head and in section

Time:07-13

What is the best practice performance-wise for adding styles to sections?

<style>
    .foo {
        [...]
    }
</style>
<div >
    [...]
</div>

or

<link rel="stylesheet" href="foo.css">
<div >
    [...]
</div>

Does the best practice differ for general styles included in head vs sections?

This is different enter image description here

CodePudding user response:

In terms of performance, inline CSS is faster as it only requires the browser to download 1 file while using external CSS will require downloading HTML and CSS files separately.

Here is the source

CodePudding user response:

** best practice **

<link rel="stylesheet" href="style.css">
  • Related