Sabrina Jewson
Sabrina Jewson

Reputation: 1518

How to automatically load a CSS file into HTML

I have a basic index.html file in a folder, as well as many, many other files. I want them all to use the same CSS file, without having to manually add to every file. I was wondering if you renamed the file index.css or something like that it would automatically load into every HTML file in the folder? Out of curiosity, is there also a Javascript method for this too?

Upvotes: 0

Views: 337

Answers (2)

Quentame
Quentame

Reputation: 355

You can't do that with simple HTML.

Do a PHP template instead, basically with:

  • head
  • header
  • nav menu
  • a content/container div/section
  • footer

Then, include your HTML/PHP page in your content.

For instance, use $_GET or $_POST to know which page to include.

Upvotes: 1

MatejMecka
MatejMecka

Reputation: 1486

Bad news my friend No. There is no magical tool that will import the CSS into all of your files. You have to do it yourself. Also it's really easy

  1. Get the CSS file
  2. Import the CSS File

See it's that easy. Was it so hard to do it?

Upvotes: 1

Related Questions