I have a question: what is the different between nav tag and div tag?
what’s the things that nav do that div can’t do?
they can both be styled, include links.
so can you please help me to understand it better?
nothing really is important for the two but is based on html5 new declaration of element tags
to fit their purpose, you can use
div on the whole site but it would be lot more confusing when trying to debug, but using
header nav article aside section footer helps you understand more about your code and how to tackle bugs… But naturally many coders use
div tag for everything…
Html5 is a more welcoming approach to readable and reusable code
Well, using semantic tags is for optimising how screen readers and search engines read your page, so it is a best practice thing to make your site more accessible and searchable
I will try to keep it simple and short. Basically every tag you use in mark up is a container, so div , nav, header, footer, section all are just wrappers. Difference is some tags are semantic (means you know what kind of content the wrapper is holding) while some aren’t. So your initial question is answered above that their’s is no difference between nav and div.
In HTML 5, it’s advised to use the semantic elements to make the website or app accessible to people with visual, auditory, mobility, or cognitive disabilities. Hence the reason for nav, header, article, section etc.
Thank you so much guys