5

My problem is that my website that I'm attempting to host with Github pages will not read the CSS that I have linked to it.

My HTML looks like this:

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="https://github.com/legoman8304/legoman8304.github.io/blob/master/style.css">
<html>
    <body>
        <h1>Hello World</h1>
        <p>I'm under construction!</p>
        <h6>Copyright MIT Licence 2018</h6>
    </body>
</html>

My CSS looks like this:

body {
  background-color: lightblue;
}

h6 {
  color: navy;
  margin-left: 20px;
}

Link repository: legoman8304.github.io

I'm guessing I linked the CSS wrong because when I using inspect element on the site itself it does show style.css but when opened it's empty. Any help?

0

2 Answers 2

5

You need to link your HTML to the github page rendered style.css and not the file itself in the repo.

Change this:

<link rel="stylesheet" type="text/css" href="https://github.com/legoman8304/legoman8304.github.io/blob/master/style.css">

To this:

<link rel="stylesheet" type="text/css" href="https://legoman8304.github.io/style.css">

And move that stylesheet reference inside your <head> tag.

Sign up to request clarification or add additional context in comments.

3 Comments

@WyattNulton So I think this issue is not code related or GitHub related anymore but browser related as can be seen here: stackoverflow.com/questions/39228657/…
Darn that's unfortunate. would inline/internal CSS be the way to go?
Wait. I figured it out. Just replace the above link with this: <link rel="stylesheet" type="text/css" href="https://legoman8304.github.io/style.css"> and it should work.
0

You can use some way:

  • Recommend: <link type="text/css" rel="stylesheet" href="style.css" />

  • Use from raw your css with href: https://raw.githubusercontent.com/legoman8304/legoman8304.github.io/master/style.css

1 Comment

GitHub doesn't allow you to do that. The best way to do is to create a Github page on repo and then use assets uploaded on repo like CSS files. for example myrepo.github.io/style.css

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.