-4

Is the order in which you place stuff inside the head section important?

Here's the thing:

I've got an HTML file with a couple of CSS stylesheets applied, and they're working just fine!

The thing is that I now want to add a background image with a very specific formatting.

1st - I tried adding that code to the main CSS stylesheet but it didn't work... (white bg/image doesn't load)

2nd - I then tried adding it to a 2nd stylesheet. It still didn't work!

3rd - Lastly I tried putting it in its own stylesheet! Still didn't work!

There must be a conflict somewhere... (I've got quite a bit of JavaScript and a lot of CSS) but unfortunately I can't post the code here :( If anybody knows of a common mistake that might be causing this, feel free to say something, if not that's fine...

And that's fine because if I place the background CSS code inside the head section IT WORKS!!!

So, my question is does it matter if I place it above or below the CSS stylesheets' links? I'm asking this simply because it's a background image that might take a couple of seconds to load and it must load completely before the rest of the content appears.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Nic
  • 1
  • 1

1 Answers1

1

Order matters differently for different things.

In the case of CSS, the order matters only in that later rules of the same specificity get applied later in the cascade.

This means that swapping two adjacent <link> elements could cause rule B to override rule A instead of vice versa.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335