geek_xed
geek_xed

Reputation: 175

How to add html styling in html page in python

I am trying to style my HTML page created using Python, but somehow I am not getting it.

Following is my code without style tags

htmlfile = open(fruit+".html")
htmlfile.write("<html>\n")
htmlfile.write("<head>\n")
htmlfile.write("<title> homepage </title>\n")
htmlfile.write("</head>\n")
htmlfile.write("<body>\n")
htmlfile.write("<h1> <center> <b> {color:red;} Fruit-properties </b> </center> </h1>\n")
htmlfile.write("</body>\n") 

anybody know how to add style tags in python?

Upvotes: 1

Views: 6618

Answers (1)

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83788

Styling of HTML is done using CSS. First you need to learn CSS basics.

Then you can either provide a separate CSS style file or style HTML code inline:

  htmlfile.write("<h1 style='color: red; text-align: center'>Fruit-properties</h1>\n")

Upvotes: 1

Related Questions