{"id":8479,"date":"2022-09-28T11:49:38","date_gmt":"2022-09-28T11:49:38","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=8479"},"modified":"2022-09-28T11:49:38","modified_gmt":"2022-09-28T11:49:38","slug":"semantic-elements-in-html5","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/09\/28\/semantic-elements-in-html5\/","title":{"rendered":"Semantic Elements in HTML5"},"content":{"rendered":"\n<p>Semantic elements are one of the most significant introductions in HTML5. In the previous versions of HTML, the generic\u00a0&lt;div>\u00a0tag with an\u00a0id\u00a0or\u00a0class\u00a0attribute was used for structuring a web page. For example, for defining sidebars, footers, menu or other structural blocks, the &lt;div> tag was used with the corresponding meaning (div class=&#8221;footer&#8221;).<\/p>\n\n\n\n<p>Semantic elements in HTML have intrinsic meaning and convey that meaning both to the browser and the developer. They clearly define what kind of content they contain (for example, the\u00a0&lt;footer>\u00a0tag is used instead of\u00a0&lt;div id=&#8221;footer&#8221;>).<\/p>\n\n\n\n<p>Let\u2019s have a look at semantic elements and their meaning.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-header-gt-element-2\">The &lt;header&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;header>\u00a0element defines a header for the document or section. It usually contains a logo, search bar, navigation links, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-header-gt-element-4\">Example of the HTML &lt;header&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      li {\n        display: inline-block;\n        margin-right: 10px;\n        color: #778899;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;header&gt;\n      &lt;nav&gt;\n        &lt;ul style=\"padding:0;\"&gt;\n          &lt;li&gt;Home&lt;\/li&gt;\n          &lt;li&gt;About us&lt;\/li&gt;\n        &lt;\/ul&gt;\n      &lt;\/nav&gt;\n      &lt;h1&gt;Welcome to our page&lt;\/h1&gt;\n      &lt;hr&gt;\n    &lt;\/header&gt;\n    &lt;article&gt;\n      &lt;header&gt;\n        &lt;h2&gt;Title of the document&lt;\/h2&gt;\n        &lt;p&gt;The content of the paragraph.&lt;\/p&gt;\n      &lt;\/header&gt;\n    &lt;\/article&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-nav-gt-element-6\">The &lt;nav&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;nav>\u00a0element defines a block of navigation links, either within the current document or to other documents. Note, that not all links in the HTML document can be placed inside the &lt;nav> element; it can only include major navigation blocks. For example, the &lt;nav> tag cannot be placed in the &lt;footer> tag for defining links in the footer of the website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-nav-gt-element-8\">Example of the HTML &lt;nav&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;header&gt;\n      &lt;h1&gt;Programming Courses&lt;\/h1&gt;\n    &lt;\/header&gt;\n    &lt;nav&gt;\n      &lt;a href=\"\/learn-html.html\"&gt;HTML&lt;\/a&gt; | &lt;a href=\"\/learn-css.html\"&gt;CSS&lt;\/a&gt; | &lt;a href=\"\/learn-javascript.html\"&gt;JavaScript&lt;\/a&gt; | &lt;a href=\"\/learn-php.html\"&gt;PHP&lt;\/a&gt; |\n    &lt;\/nav&gt;\n    &lt;h2&gt;Welcome to W3Docs!&lt;\/h2&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-article-gt-element-10\">The &lt;article&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;article>\u00a0element is used to specify an independent, self-contained content (articles, blog posts, comments, etc.). The content of the element has its meaning, and it is easily differentiated from the rest of the webpage content.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-article-gt-element-12\">Example of the HTML &lt;article&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;article&gt;\n      &lt;h1&gt;Title of the article&lt;\/h1&gt;\n      &lt;p&gt;Text of the article&lt;\/p&gt;\n    &lt;\/article&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-section-gt-element-14\">The &lt;section&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;section>\u00a0element is used to group standalone sections within a webpage containing logically connected content (news block, contact information etc.).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-section-gt-element-16\">Example of the HTML &lt;section&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Using the section tag&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;section&gt;\n      &lt;h1&gt;Hypertext markup language HTML&lt;\/h1&gt;\n      &lt;p&gt;HTML is the standard markup language for creating web pages and web applications. Browsers receive HTML documents from a web server or from local storage and render the documents into multimedia web pages. HTML describes the structure of a web page semantically and originally included cues for the appearance of the document.&lt;\/p&gt;\n    &lt;\/section&gt;\n    &lt;section&gt;\n      &lt;h1&gt;CSS&lt;\/h1&gt;\n      &lt;p&gt;A formal language that is used as a description zone, formatting the appearance of a web page written with the help of markup languages HTML and XHTML but it can be applied to any XML-document, for example, to SVG or XUL.&lt;\/p&gt;\n    &lt;\/section&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-aside-gt-element-18\">The &lt;aside&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;aside>\u00a0element defines a section with additional information related to the content around the &lt;aside> element. It is generally used to enhance an article with additional information, or highlight the parts that can be interesting to the user.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-aside-gt-element-20\">Example of the HTML &lt;aside&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;I like watching Game of Thrones.&lt;\/p&gt;\n    &lt;aside&gt;\n      &lt;h4&gt;Game of Thrones&lt;\/h4&gt;\n      &lt;p&gt;Game of Thrones is an American fantasy drama television series created by David Benioff and D. B. Weiss. It is an adaptation of A Song of Ice and Fire, George R. R. Martin's series of fantasy novels&lt;\/p&gt;\n    &lt;\/aside&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-footer-gt-element-22\">The &lt;footer&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;footer>\u00a0element defines the footer of a web page or a section. As a rule, it contains copyright information, contact details, navigation links, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-footer-gt-element-24\">Example of the HTML &lt;footer&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n    &lt;style&gt;\n      .header {\n        height: 40px;\n        padding: 20px 20px 0;\n        background: #e1e1e1;\n      }\n      .main-content {\n        height: 60vh;\n        padding: 20px;\n      }\n      footer {\n        padding: 10px 20px;\n        background: #666;\n        color: white;\n      }\n      a {\n        color: #00aaff;\n      }\n    &lt;\/style&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class=\"header\"&gt;Header \/ Menu&lt;\/div&gt;\n    &lt;div class=\"main-content\"&gt;\n      &lt;h1&gt;Main content&lt;\/h1&gt;\n      &lt;p&gt;This is some paragraph. &lt;\/p&gt;\n    &lt;\/div&gt;\n    &lt;footer&gt;\n      &lt;p&gt;Company \u00a9 W3docs. All rights reserved.&lt;\/p&gt;\n    &lt;\/footer&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-address-gt-element-26\">The &lt;address&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;address>\u00a0element is used to provide contact information of the author or the owner of an article, document or the website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-address-gt-element-28\">Example of the HTML &lt;address&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;address&gt;\n      Author: W3docs Team&lt;br \/&gt;\n      &lt;a href=\"mailto:info@w3docs.com\"&gt;Send Mail to the Author&lt;\/a&gt;\n    &lt;\/address&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-main-gt-element-30\">The &lt;main&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;main>\u00a0element defines the main content of the page. The content of the &lt;main> tag must be unique and not duplicate blocks of the same type that are repeated in other documents, such as the header of a site, footer, menu, search, copyright information, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-main-gt-element-32\">Example of the HTML &lt;main&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;main&gt;\n      &lt;h1&gt;Programming languages&lt;\/h1&gt;\n      &lt;p&gt;Languages HTML and CSS are intended for site layout.&lt;\/p&gt;\n      &lt;article&gt;\n        &lt;h2&gt;HTML&lt;\/h2&gt;\n        &lt;p&gt; HTML (Hyper Text Markup Language) is a language of hypertext markup, which is used to create web pages. &lt;\/p&gt;\n        &lt;p&gt;... &lt;\/p&gt;\n        &lt;p&gt;... &lt;\/p&gt;\n      &lt;\/article&gt;\n      &lt;article&gt;\n        &lt;h2&gt;CSS&lt;\/h2&gt;\n        &lt;p&gt;CSS is a language of styles, defining the display of HTML documents. &lt;\/p&gt;\n        &lt;p&gt;... &lt;\/p&gt;\n      &lt;\/article&gt;\n    &lt;\/main&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-figure-gt-element-34\">The &lt;figure&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;figure>\u00a0element is used for indicating self-contained content. The tag can include images, diagrams, illustrations, code examples, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-figure-gt-element-36\">Example of the HTML &lt;figure&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;A cute baby&lt;\/p&gt;\n    &lt;figure&gt;\n      &lt;img src=\"\/uploads\/media\/default\/0001\/01\/25acddb3da54207bc6beb5838f65f022feaa81d7.jpeg\" alt=\"A Cute Baby\" width=\"250\" height=\"200\"&gt;\n    &lt;\/figure&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-figcaption-gt-element-38\">The &lt;figcaption&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;figcaption>\u00a0element is used for adding signature or annotation to the &lt;figure> tag.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-figcaption-gt-element-40\">Example of the HTML &lt;figcaption&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;Image of a baby&lt;\/p&gt;\n    &lt;figure&gt;\n      &lt;img src=\"\/uploads\/media\/default\/0001\/01\/25acddb3da54207bc6beb5838f65f022feaa81d7.jpeg\" alt=\"A Cute Baby\" width=\"250\" height=\"200\"&gt;\n      &lt;figcaption&gt;Fig.1 \u2013 Cute baby&lt;\/figcaption&gt;\n    &lt;\/figure&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-time-gt-element-42\">The &lt;time&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;time>\u00a0element defines a human-readable time on a 24-hour clock or a precise date in the Gregorian calendar.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-time-gt-element-44\">Example of the HTML &lt;time&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document.&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;The game will be held on&lt;time datetime=\"2018-09-28 19:00\"&gt;September 28&lt;\/time&gt;.&lt;\/p&gt;\n    &lt;p&gt;It will start at &lt;time&gt;19:00&lt;\/time&gt;&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-mark-gt-element-46\">The &lt;mark&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;mark>\u00a0element is used to mark a part of the text which has relevance. It can be used to highlight a text for showing emphasis, highlight search terms in search results to provide context, or distinguish a new content added by the user by showing it differently.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-mark-gt-element-48\">Example of the HTML &lt;mark&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;Learn HyperText markup language (HTML) on &lt;mark&gt;W3Docs.com&lt;\/mark&gt; website.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-bdi-gt-element-50\">The &lt;bdi&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;bdi>\u00a0element is used to isolate bidirectional text when a language with a right-to-left directionality, such as Arabic or Hebrew, is used inline with left-to-right languages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-bdi-gt-element-52\">Example of the HTML &lt;bdi&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the documnet&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;h1&gt; Example of using the bdi element &lt;\/h1&gt;\n    &lt;p dir=\"ltr\"&gt;&lt;bdi&gt;\u0623\u0631\u0645\u064a\u0646\u064a\u0627 \u062c\u0645\u064a\u0644\u0629&lt;\/bdi&gt; This sentence in Arabic is automatically displayed from right to left.&lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-lt-wbr-gt-element-54\">The &lt;wbr&gt; element<\/h3>\n\n\n\n<p>The\u00a0&lt;wbr>\u00a0tag is used to instruct the browser, where a line-break could be added in the text. Unlike the &lt;br> tag, which obliges the browser to insert a line-break, in the case of &lt;wbr> the browser first analyzes its content, and then inserts a line-break if necessary (too long word or URL address).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-of-the-html-lt-wbr-gt-element-56\">Example of the HTML &lt;wbr&gt; element:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Title of the document&lt;\/title&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;p&gt;Example of a long string of text without wbr.&lt;\/p&gt;\n    &lt;p&gt;This is the longest word you can ever meet in the English language pneumonoultramicroscopicsilicovolcanoconiosis&lt;\/p&gt;\n    &lt;p&gt;Example of a long string of text with wbr.&lt;\/p&gt;\n    &lt;p&gt;This is the longest word you can ever meet in the English language pneumono&lt;wbr&gt;ultra&lt;wbr&gt;micro&lt;wbr&gt;scopic&lt;wbr&gt;silico&lt;wbr&gt;volcano&lt;wbr&gt;coniosis&lt;\/p&gt;\n    &lt;\/p&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Semantic elements are one of the most significant introductions in HTML5. In the previous versions of HTML, the generic\u00a0&lt;div>\u00a0tag with an\u00a0id\u00a0or\u00a0class\u00a0attribute was used for structuring a web page. For example, for defining sidebars, footers, menu or other structural blocks, the &lt;div> tag was used with the corresponding meaning (div class=&#8221;footer&#8221;). Semantic elements in HTML have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[425],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8479"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=8479"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/8479\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=8479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=8479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=8479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}