简体   繁体   中英

How do I link my CSS to the HTML file in Github Pages?

I need some help here.. I tried different links but it does not load the CSS file..

<link rel="stylesheet" type="text/css" 
      href="https://github.com/cengizkirazjs.github.io/cengizkiraz.github.io/styles.css">

This is the page and the outcome: https://cengizkirazjs.github.io/cengizkiraz.github.io/

Any advice? Its my first time linking CSS with HTML on Github!

As it was said in the comments, what do you think about changing file path a bit?

In your code we have this line

<link rel="stylesheet" type="text/css" href="cengizkiraz.github.io/styles.css">

It contains an absolute path. If you want to stick to this method, maybe just add a protocol, like this

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

But it would be better if you use relative paths

In this case, our <link> will look like this

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

It means that HTML will search for this file in folder, where.html file is saved. Looks slightly better, doesn't it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM