r/HTML • • Oct 11 '26

stylesheet not connecting

Back again with more homework issues. I'm supposed to be making a stylesheet for a pre-written website. For some reason, nothing from my stylesheet is showing up. This is the same code that worked fine on my last assignment, so I'm really not sure what's wrong

<head>

<title>Planets in our Solar System</title>

<meta charset="utf-8">

<link rel="stylesheet" type="text/css" href="planets.css">

</head>

The Stylesheet code looks like this so far

<style>

* {

box-sizing: border-box;

margin: 0;

}

    body {

        background-color: silver;

    }

    a:link {

        color: fuchsia;

    }



    a:visited {

        color: red;

    }



    a:hover {

        color: blue;

    }



    a:active {

        color: olive;

    }



    .planet {

        border-style: solid;

        border-width: medium;

        border-color: purple;

        background-color: orchid;

    }



</style>
1 Upvotes

12 comments sorted by

8

u/AmanBabuHemant Oct 11 '26

the stylesheet code (planets.css) should not have <style> and </style>, it is a CSS file, which contain rules directly, <style> tag are used to embed CSS in HTML.

1

u/TrainingQuantity3744 Oct 11 '26

thanks for that. Looks like none of the css changes are showing up still. Neither are any changes to my html file

1

u/armahillo Expert Oct 11 '26

are both files in the same folder?

1

u/TrainingQuantity3744 Oct 11 '26

all files are in the same folder

1

u/AmanBabuHemant Oct 11 '26

can you confirm the place of the CSS file ?

by the linking I am assuming the file should be in the same directory in which the html file is, if this is not tha case than you would need to relocate.

if this doesn't hale open the html in your browser, then from inspect find your linking open that link from there you will directed to the css file, if you found nothing means your file is not where it suppose to be, if you found your file's content there... then you can send the source code : )

1

u/AshleyJSheridan Oct 12 '26

Look in the network tab of the browser, what does it say about that stylesheet when it attempts to fetch it?

1

u/TrainingQuantity3744 Oct 14 '26

Ok, so turns out I somehow ended up saving like 5 copies of my html file. The one I was opening was not the same as the one I was editing. Not really sure how that happened, but it seems to be fixed now

2

u/frownonline Oct 11 '26

Ctrl + F5 to force reload the page.

Has your HTML got a doctype tag?

1

u/aunderroad Oct 11 '26

Maybe double check and see:

  1. if your .css file is called "planets.css" (the file is case sensitive)
  2. the "planets.css" file path is correct
  3. in the planets.css, you do not need use the style tag.
  4. If that does not work, inspect your page and check your "Network" panel and check the ".css" section. You might have to refresh your page.

1

u/[deleted] Oct 12 '26

Check the path to the planets.css file. It should be an absolute path from the root of the website.

1

u/TabbbyWright Oct 12 '26

If you haven't figured this out yet (I see it was posted 12 hours ago): make sure the file you're editing is in fact the correct file in the correct location.

Also make sure that your CSS file isn't actually named planets.css.txt or something.

1

u/SheepherderSavings17 Oct 12 '26

How are you serving html?