How to link my CSS to my HTML in a github hosted site

后端 未结 3 2070
太阳男子
太阳男子 2020-12-20 10:03

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:



        
相关标签:
3条回答
  • 2020-12-20 10:05

    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.

    0 讨论(0)
  • 2020-12-20 10:13

    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

    0 讨论(0)
  • 2020-12-20 10:22

    Guys i had the same problem but i solved it's easy guys, change your code to

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

    actually the problem is with time ,after commit u have to wait a bit to propagate the same to github

    Also frequently check the page source whether its updated on ur browser actually while we edit offline it will not take time but its opposite in online world so wait for 10-20 sec and frequently check whether your site is updated by reloading page source or website it will work definitely

    0 讨论(0)
提交回复
热议问题