+ 1
I taught the style was coded inside the head tag why is it working in the <body>?
3 Antworten
+ 2
css extent file use in head tag. style tag in body. diffrents external file is for largest css files. style tag for minor stuff. you understand ?
+ 1
To an extent, it will work wherever you put it. The reason it should be in the head is so the styles apply to the whole dom. If you have elements that should be styled by the css file appearing before the stylesheet is linked, they wont style correctly. That's what the cascading in css means. The styles "cascade" down the dom.
0
It works anywhere, but it is better to put it in the <head> element.
It is always better to use it externally and link it with the HTML file via the <link> element between the <head> element. It helps apply the styles correctly.