Header | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Header

In the W3schools website, I've seen something weird I learned some tags like (header, main, footer) for example when we want to create a header we do like this <header> <h1>This is my header</h1> </header> But in W3schools they only did this with div <div class="header"> <h1>This is my header</h1> </div> But all I know is this way is wrong we use header tag to clarify for search engines that this is my website's header Am I wrong? please tell me some details I always use header tag and inside that, I use div to separate my sections in the header like my logo my navigation menu, etc.

3rd Jul 2020, 3:59 PM
coal
coal - avatar
2 Answers
+ 3
Both are same. Different websites use different methods and in HTML5 same result can be obtained by using different tags. People are going to enjoy our websites by look and feel. They are not going to find out whether you used div or not....✌️😊
3rd Jul 2020, 4:14 PM
Sandy Sandeep
Sandy Sandeep - avatar
+ 1
They are both the same. The header tag was introduced by HTML5, before that the header, nav, footer, aside and some equivalent tags, in terms of referring to a particular part of the webpage, were obtained by using a div tag with a class name. According to my knowledge, these tags describe your page better for the search engine than regular divs which makes them a better choice.
3rd Jul 2020, 10:08 PM
Ali Abdelhady
Ali Abdelhady - avatar