

{"id":78661,"date":"2020-07-03T09:00:48","date_gmt":"2020-07-03T03:30:48","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=78661"},"modified":"2024-07-26T13:13:20","modified_gmt":"2024-07-26T07:43:20","slug":"html-id-attribute","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/","title":{"rendered":"HTML ID Attribute Syntax and Example"},"content":{"rendered":"<p>In this HTML Tutorial, we are going to learn about HTML id Attribute and its uses. So let&#8217;s start!!!<\/p>\n<h2>HTML ID Attribute<\/h2>\n<p>Id attribute is useful to identify a particular element in the document uniquely. It can be used with at most one element. It also acts as a distinguisher between two or more elements with the same name. HTML ID is widely used to style a particular element using CSS or perform a task on it using JavaScript.<\/p>\n<p>IDs are considered important in web development for creating interactive and user-friendly websites. They help in managing and manipulating specific elements efficiently, making the development process more streamlined.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78955\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg\" alt=\"html id attribute\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h2>Usage of Id Attribute in HTML<\/h2>\n<ul>\n<li>The id value can be accessed by CSS and JavaScript for styling and performing specific tasks respectively.<\/li>\n<li>id of an element is case sensitive and must contain at least one character.<\/li>\n<li>The id attribute can be applied to all the elements.<\/li>\n<\/ul>\n<p>Using IDs in HTML also helps in styling and scripting along with enhancing accessibility. Screen readers can navigate to elements with specific IDs which further improves the user experience for visually impaired users. Also, the search engines use IDs to understand the content structure better.<\/p>\n<p><strong>Syntax-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;tagname id=\u201d\u201d&gt;&lt;\/tagname&gt;<\/pre>\n<h3>Example of HTML ID Attribute<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n&lt;head&gt; \r\n    &lt;title&gt;DataFlair id attribute&lt;\/title&gt; \r\n    &lt;style&gt;  \r\n        #DataFlair { \r\n            font-size:50px; \r\n            font-weight:bold; \r\n            text-align:center; \r\n         } \r\n         #Article { \r\n             text-align:center; \r\n             font-size:50px; \r\n         } \r\n    &lt;\/style&gt; \r\n&lt;\/head&gt; \r\n&lt;body&gt; \r\n    &lt;div id=\"DataFlair\"&gt;DataFlair&lt;\/div&gt; \r\n    &lt;div id=\"Article\"&gt;E-learning&lt;\/div&gt; \r\n&lt;\/body&gt; \r\n&lt;\/html&gt;  \r\n<\/pre>\n<p>(Here, two divisions with id DataFlair and Article have been created and styled with CSS. \u2018#\u2019 is used to access these elements with id).<\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image1basic-example.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78958\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image1basic-example.png\" alt=\"html id attribute\" width=\"392\" height=\"207\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image1basic-example.png 392w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image1basic-example-300x158.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image1basic-example-150x79.png 150w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a><\/p>\n<p><strong>Note-<\/strong> The ID of an element must contain at least one character and should be devoid of spaces.<\/p>\n<h2>Difference between HTML Class and HTML ID<\/h2>\n<p>Each element in an HTML document can have only one unique ID and that ID is used to access that particular element only. On the other hand, multiple elements can have the same class and a single element can belong to multiple classes.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;style&gt;\r\n\/* Style the element with the id \"myId\" *\/\r\n#myId {\r\n  background-color: lightblue;\r\n  color: black;\r\n  padding: 40px;\r\n  text-align: center;\r\n}\r\n\r\n\/* Style all elements with the class name \"courses\" *\/\r\n.courses {\r\n  background-color: tomato;\r\n  color: white;\r\n  padding: 10px;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1 id=\"myId\"&gt;My Courses&lt;\/h1&gt;\r\n&lt;!-- Multiple similar elements --&gt;\r\n&lt;h2 class=\"city\"&gt;HTML5&lt;\/h2&gt;\r\n&lt;h2 class=\"city\"&gt;Python&lt;\/h2&gt;\r\n&lt;h2 class=\"city\"&gt;Machine Learning&lt;\/h2&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78959\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id.png\" alt=\"difference between html class and id\" width=\"745\" height=\"346\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id.png 745w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id-300x139.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id-150x70.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image2difference-between-class-and-id-520x242.png 520w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><\/a><\/p>\n<h2>HTML Bookmarks<\/h2>\n<p>If a web-page is too long, it would be a tedious task to jump to its specific portions. To facilitate this, link bookmarks can be used. For this, the ID of the element is given as the link. For example,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt; \r\n&lt;body&gt;  \r\n&lt;p&gt;&lt;a href=\"#T11\"&gt;Jump to Topic 11&lt;\/a&gt;&lt;\/p&gt; &lt;!--link the ID in href--&gt;\r\n&lt;p&gt;&lt;a href=\"#T17\"&gt;Jump to Topic 17&lt;\/a&gt;&lt;\/p&gt; \r\n&lt;p&gt;&lt;a href=\"#T20\"&gt;Jump to Topic 20&lt;\/a&gt;&lt;\/p&gt; \r\n&lt;h2&gt;Topic 1&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 2&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 3&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 4&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 5&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 6&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 7&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1&lt;\/p&gt; \r\n&lt;h2&gt;Topic 8&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 9&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 10&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2 id=\"T11\"&gt;Topic 11&lt;\/h2&gt; &lt;!--create an ID--&gt;\r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 12&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 13&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 14&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 15&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 16&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2 id=\"T17\"&gt;Topic 17&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 18&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2&gt;Topic 19&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt; \r\n&lt;h2 id=\"T20\"&gt;Topic 20&lt;\/h2&gt; \r\n&lt;p&gt;paragraph 1 &lt;\/p&gt;  \r\n&lt;\/body&gt; \r\n&lt;\/html&gt;  \r\n<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78960\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark.png\" alt=\"html bookmarks\" width=\"1227\" height=\"810\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark.png 1227w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark-300x198.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark-1024x676.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark-150x99.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark-768x507.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-3bookmark-520x343.png 520w\" sizes=\"auto, (max-width: 1227px) 100vw, 1227px\" \/><\/a><\/p>\n<h2>JavaScript and ID Attribute in HTML<\/h2>\n<p>In order to perform task on a particular element, ID attribute is useful. The getElementByID() method is used here. For example,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n    &lt;head&gt; \r\n        &lt;style&gt; \r\n            #dataflair { \r\n                font-size:50px; \r\n                color:blue;\r\n                font-weight:bold; \r\n                margin-bottom:10px; \r\n            } \r\n        &lt;\/style&gt; \r\n        &lt;script&gt; \r\n        function DataFlair() { \r\n        document.getElementById(\"dataflair\").innerHTML =  \r\n                             \"Welcome to DataFlair E-learning\"; \r\n        document.getElementById(\"dataflair\").style.color = \"black\"; \r\n    } \r\n    &lt;\/script&gt; \r\n    &lt;\/head&gt; \r\n    &lt;body&gt; \r\n    &lt;div id=\"dataflair\"&gt;DataFlair&lt;\/div&gt; \r\n    &lt;button onclick=\"DataFlair()\"&gt;Text change&lt;\/button&gt;  \r\n    &lt;\/body&gt; \r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Output-<\/strong><br \/>\nBefore-<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-4beforejavascript-and-id-attribute.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78961\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-4beforejavascript-and-id-attribute.png\" alt=\"javascript and id attribute\" width=\"398\" height=\"154\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-4beforejavascript-and-id-attribute.png 398w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-4beforejavascript-and-id-attribute-300x116.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-4beforejavascript-and-id-attribute-150x58.png 150w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/a><\/p>\n<p>After-<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78962\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute.png\" alt=\"javascript and id attribute in html\" width=\"964\" height=\"152\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute.png 964w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute-300x47.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute-150x24.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute-768x121.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Image-5afterjavascript-and-id-attribute-520x82.png 520w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/a><\/p>\n<h2>HTML Supported Browsers<\/h2>\n<ul>\n<li>Google Chrome<\/li>\n<li>Mozilla<\/li>\n<li>Internet Explorer<\/li>\n<li>Safari<\/li>\n<li>Opera<\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>The ID attribute in HTML 5 is useful to uniquely identify element. This element can be styled using CSS and dynamic tasks can be performed on it using any scripting language. In this article, we\u2019ve looked at the syntax of ID attributes, accessing it using CSS and JavaScript and using it to create bookmarks. We\u2019ve also discussed the differences between class, and ID attributes of HTML5.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this HTML Tutorial, we are going to learn about HTML id Attribute and its uses. So let&#8217;s start!!! HTML ID Attribute Id attribute is useful to identify a particular element in the document&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":78955,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22400],"tags":[22499,22500],"class_list":["post-78661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html","tag-html-id-attribute","tag-id-attribute-in-html"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>HTML ID Attribute Syntax and Example - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn what is HTML id attribute and what are its uses. Learn its syntax and examples for better understanding. See Difference between HTML Class and HTML ID\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/html-id-attribute\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML ID Attribute Syntax and Example - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn what is HTML id attribute and what are its uses. Learn its syntax and examples for better understanding. See Difference between HTML Class and HTML ID\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/html-id-attribute\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-03T03:30:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-26T07:43:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML ID Attribute Syntax and Example - DataFlair","description":"Learn what is HTML id attribute and what are its uses. Learn its syntax and examples for better understanding. See Difference between HTML Class and HTML ID","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/","og_locale":"en_US","og_type":"article","og_title":"HTML ID Attribute Syntax and Example - DataFlair","og_description":"Learn what is HTML id attribute and what are its uses. Learn its syntax and examples for better understanding. See Difference between HTML Class and HTML ID","og_url":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-07-03T03:30:48+00:00","article_modified_time":"2024-07-26T07:43:20+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"HTML ID Attribute Syntax and Example","datePublished":"2020-07-03T03:30:48+00:00","dateModified":"2024-07-26T07:43:20+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/"},"wordCount":456,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg","keywords":["HTML ID Attribute","id attribute in html"],"articleSection":["HTML Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/html-id-attribute\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/","url":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/","name":"HTML ID Attribute Syntax and Example - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg","datePublished":"2020-07-03T03:30:48+00:00","dateModified":"2024-07-26T07:43:20+00:00","description":"Learn what is HTML id attribute and what are its uses. Learn its syntax and examples for better understanding. See Difference between HTML Class and HTML ID","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/html-id-attribute\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/html-id-attribute-df.jpg","width":1200,"height":628,"caption":"html id attribute"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/html-id-attribute\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"HTML Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/html\/"},{"@type":"ListItem","position":3,"name":"HTML ID Attribute Syntax and Example"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dd6de0d647a0185cd6faf264e4ba860b0d85d08d7070766f9cd41bea5bb0b227?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team is passionate about delivering top-notch tutorials and resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With expertise in the tech industry, we simplify complex topics to help learners excel. Stay updated with our latest insights.","url":"https:\/\/data-flair.training\/blogs\/author\/dfadteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=78661"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78661\/revisions"}],"predecessor-version":[{"id":142923,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78661\/revisions\/142923"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/78955"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=78661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=78661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=78661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}