ShekharD
ShekharD

Reputation: 11

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.

Upvotes: 1

Views: 1087

Answers (2)

I_Al-thamary
I_Al-thamary

Reputation: 3993

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>

Upvotes: 1

user16563995
user16563995

Reputation:

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">

Upvotes: 0

Related Questions