1

I'm creating a simple page using python 3.4 and generating HTML. However the stylesheets don't load. Here is my code:

`#!/Python34/python
content ="""<html>
<head>
<meta charset="utf-8">
<title>Spain National Team</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<!---Body Stuff--->
</body>
</html>"""
print(content)`

Checking the source of the webpage,it's a well formed HTML document, but the styles don't load. My python script and css are in the same directory: xampp/cgi-bin/sports/index.py and xampp/cgi-bin/sports/styles.css

1
  • 1
    add type attribute to the link tag type="text/css"... hope it helps Commented Jun 9, 2017 at 6:42

1 Answer 1

1

If you want to open it on your default browser,

import webbrowser
content ='<html>\n<head>\n<meta charset="utf-8">\n<title>Spain National Team</title>\n<link rel="stylesheet" href="styles.css"/>\n</head>\n<body>\n<button></button>\n</body>\n</html>'

html_file = open('sample.html', 'w')
html_file.write(content)
flnme="sample.html"
webbrowser.open_new_tab(flnme)
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.