4

I'm trying to use an external css file in my html file. At first I used bootstrap framework and it works well. However, when I tried to customize the web page by adding a customized css file, it doesn't work at all! Here is my code:

    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css">
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="custom.css" type="text/css">

custom.css:

body{
background-color: #9acfea;}

Here I just want to change the background color.

'custom.css' is under the same path with the HTML file. Also, I've tried to only apply 'custom.css', so I create a new HTML file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="custom.css" type="text/css"/>
</head>
<body>
    hello
</body>
</html>

It doesn't work either. I'm confused. Why the bootstrap css file works perfect but the customized file doesn't? By the way, I'm using the Flask framework, but I don't think it matters. Any suggestions would be appreciate!

4
  • add full path to CSS. See - bootstraps files use full path. Commented Jan 31, 2016 at 10:05
  • and YES, it can have matter that you use Flask. It is not PHP. Flask can have HTML files in templates folder but browser see it as different folder. Flask use route to change this path. But it doesn't change paths for static files. Commented Jan 31, 2016 at 10:11
  • read about static files in Flask. Commented Jan 31, 2016 at 10:13
  • @furas Thanks a lot! Your answer helps me perfectly! Commented Jan 31, 2016 at 12:31

1 Answer 1

2
<link href="{{ url_for('static', filename='custom.css') }}" rel="stylesheet"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.