简体   繁体   中英

How can I link my external css file to my html file in Pycharm?

Inside the project folder, I have created both the html and CSS file under 'venv' library root folder. html file name - index.html CSS file name - styles.css

code that I used to link CSS: <link rel="stylesheet" href="styles.css" type="text/css">

This does not seem to work. Need help.

CSS is not available in PyCharm Community but it will work perfectly in the Professional edition. Also, if you face a problem with the static file use href="{% static "static/d.css"%}" and change the setting.py You can see how to add it . I run the code below in PyCharm 2021.3.1 (Professional edition) .

 body { background-color: lightblue; } h1 { color: navy; margin-left: 20px; }
 <.DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="d.css" type="text/css" /> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

I am not sure but check it. you can add the folder what the css file is found. like this: <link rel="stylesheet" href="../root/styles.css" type="text/css">

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