HTML5 SemanticsIn any language, it is essential to understand the meaning of words during communication. And if this is a computer communication then it becomes more critical. So HTML5 provides more semantic elements which make easy understanding of the code. Hence Semantics defines the meaning of words and phrases, i.e. Semantic elements= elements with a meaning. Semantic elements have a simple and clear meaning for both, the browser and the developer. For example:In HTML4 we have seen <div>, <span> etc. are which are non-semantic elements. They don't tell anything about its content. On the other hand, <form>, <table>, and <article> etc. are semantic elements because they clearly define their content. HTML5 semantic elements are supported by all major browsers. Why to use semantic elements?In HTML4, developers have to use their own id/class names to style elements: header, top, bottom, footer, menu, navigation, main, container, content, article, sidebar, topnav, etc. This is so difficult for search engines to identify the correct web page content. Now in HTML5 elements (<header> <footer> <nav> <section> <article>), this will become easier. It now allows data to be shared and reused across applications, enterprises, and communities." Semantic elements can increase the accessibility of your website, and also helps to create a better website structure. Semantic Elements in HTML5
Some important semantic elements in HTML5HTML5 <article> ElementHTML <article> element defines article content within a document, page, application, or a website. It can be used to represent a forum post, a magazine, a newspaper article, or a big story. Example:Test it NowHTML5 <aside> ElementThe <aside> element represent the content which is indirectly giving information to the main content of the page. It is frequently represented as a sidebar. Example:Test it NowHTML5 <section> ElementThe <section> element is used to represent the standalone section within an HTML document. A page can have various sections and each section can contain any content, but headings for each section is not mandatory. Example:Test it NowNesting <article> tag in <section> tag or Vice Versa?We know that the<article> element specifies independent, self-contained content and the <section> element defines section in a document. In HTML, we can use <section> elements within <article> elements, and <article> elements within <section> elements. We can also use <section> elements within <section> elements, and <article> elements within <article> elements. For example:In a newspaper, the sport <article> in the sport section, may have a technical section in each <article>. HTML5 <nav> ElementThe HTML <nav> element is used to define a set of navigation links. Example:Test it NowHTML5 <header> ElementThe <header> element represent the header of the document which can contain introductory content or navigation links. Example:Test it NowHTML5 <footer> ElementThe <footer> tag defines the footer of an HTML document or page. Example:Test it NowNext TopicHTML5 Migration |