I am going to install a banner in the website, which target to run of the entire website. The banner is set to position:fixed
& bottom:0px
so it will be a floating banner at the bottom.
My website structure is a common header file, with many body files which corresponding to different pages.
If I put this DIV in the common header file (the <head>
section), it will automatically achieve the result. However, if I put this DIV in the body files instead (the <body>
section), I have to open the body documents one by one and add the DIV for so many times.
I see that on the Internet, people always don't recommend to put a DIV in <head>
section. May I know the reason? Is there any harm? As I have tested by myself, it seems there's not much difference.
If I understand your question, you want to know the reason people say not to put div in < head > tags.
Well, the reason is that by doing that, the user experience will be unpredictable. Many years ago, there were no strict standards and the experience of each web page on different user agents was different. So W3C made more strict standards so that however the page displays on one web browser, it should display the same on a different browser.
Now if you test the correctness of your website by pasting your code on their validator, you will see that it will not pass the tests.
And for your information, < header > section and < head > are different (just in case you want mix them up). You can put divs in < header > as of HTML5, but never in < head >.
Further reading: