Why does style tag in html doesn't work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
15th Dec 2021, 8:19 AM
Slogo
Slogo - avatar
9 Answers
+ 7
Because, You Didn't Choose Any Element To Style! You Have To Choose The Element To Style Like: element{ /* The CSS Code */ }
15th Dec 2021, 9:54 AM
Sancho Godinho
Sancho Godinho - avatar
+ 4
You have to include an element like div{ background: ; }
15th Dec 2021, 10:53 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar
+ 2
Sancho Godingo what do you mean?
15th Dec 2021, 1:04 PM
Slogo
Slogo - avatar
+ 2
That, You Didn't Add An Element That You're Targeting To Style... You Directly Wrote The Style But, For Which Element? So, Choose The Element By My Above Answer. If You Still Didn't Understand, Go Through The HTML & CSS Course Again...
16th Dec 2021, 11:31 AM
Sancho Godinho
Sancho Godinho - avatar
+ 2
If You Want It For The Body Tag, Then Use: body{ /* The Code You Wrote In The Style Tag */ }
16th Dec 2021, 11:44 AM
Sancho Godinho
Sancho Godinho - avatar
+ 1
Sancho Godingo do you mean like body{ } or *{ }
16th Dec 2021, 11:41 AM
Slogo
Slogo - avatar
+ 1
Specify any tag element in the body section, like <h1> <p> <div> tags, etc. And style the content with either id or class class attribute, in the style section.
16th Dec 2021, 9:48 PM
Emmanuel Pascal
+ 1
You need to define the element that the style will be applied to. If you want it to be the background to the body for example: Body{ Background: … } But if you only want it for divs with a class bg; .bg { Background: … }
17th Dec 2021, 2:17 AM
Edison Castejon
0
style tag will work in head section of html style attribute is allowed in all tags of html
15th Dec 2021, 12:45 PM
sree harsha
sree harsha - avatar