Nikunj Gupta
Nikunj Gupta

Reputation: 126

link for cdn file not working with html

The HTML code given below does not follow the stylesheet that is provided in the link.
See the following code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Demo </title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />

    <link href="https://raw.githubusercontent.com/nkg447/static/master/static/bootstrap3/css/bootstrap.css" rel="stylesheet" />


</head>
<body>

<div class='container'>
    <h1>nofacebook </h1>
    <h4 align="right"></h4>
    <ul class="nav nav-pills ct-blue">

              <li><a href="/">Home</a></li>

              <li><a href="/register/">Register</a></li>

              <li><a href="/login/">Login</a></li>

              <li><a href="/about/">About</a></li>

              <li><a href="/contact/">Contact</a></li>

        </ul>
</div>
</body>
</html>

The above code does not style the HTML as per the CSS link

<link href="https://raw.githubusercontent.com/nkg447/static/master/static/bootstrap3/css/bootstrap.css" rel="stylesheet" />

Upvotes: 0

Views: 1319

Answers (3)

Alex
Alex

Reputation: 9041

github isn't a CDN.

Try using the bootstap CDN - bootstrapcdn.com

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet" />

It styles the page as expected - https://jsfiddle.net/ajthomascouk/4sm9cs00/

Upvotes: 0

Andreas Andersson
Andreas Andersson

Reputation: 566

If you open the developer tools you will see a warning telling you that the css file is transfered as a file instead of stylesheet and therefor not loaded.

GitHub is not a cdn storage and do not support this.

I suggest that you read bootstraps website https://getbootstrap.com/docs/3.3/getting-started/ and use one of the cdns that they recommend there instead

Upvotes: 0

Kristiyan Kostadinov
Kristiyan Kostadinov

Reputation: 3712

It's because GitHub really isn't meant to be used as a CDN and as such it serves the file as plain text. You can use this link instead:

https://cdn.rawgit.com/nkg447/static/master/static/bootstrap3/css/bootstrap.css

Upvotes: 3

Related Questions