

{"id":78650,"date":"2020-06-29T09:00:56","date_gmt":"2020-06-29T03:30:56","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=78650"},"modified":"2024-07-26T13:19:09","modified_gmt":"2024-07-26T07:49:09","slug":"html-links-and-hyperlinks","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/","title":{"rendered":"Create HTML Links and Hyperlinks to Connect Web Pages"},"content":{"rendered":"<p>Links, predominantly, are used to link various web-pages or HTML documents with each other. In other words, it is a connection between the source and the destination. These links are often referred to as hyperlinks that enable users to navigate between web-pages through text, images, phrases, etc.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78796\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg\" alt=\"HTML Links\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<p>Links are specified using anchor or &lt;a&gt; tag.<\/p>\n<p>Syntax for HTML Links:<br \/>\n<strong>&lt;a href=\u201dURL of the web-page or HTML document\u201d&gt;Text&lt;\/a&gt;<\/strong><\/p>\n<p>Here, href is used to specify the destination of the hyperlink that will be created. Text is the content that will appear on the hyperlink.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n &lt;h3&gt;Example Of a link&lt;\/h3&gt; \r\n   &lt;body&gt; \r\n      &lt;p&gt;Click on the following link&lt;\/p&gt; \r\n      &lt;a href = \"https:\/\/data-flair.training\/\"&gt;DataFlair&lt;\/a&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\/06\/pasted-image-0-17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78797\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-17.png\" alt=\"Links in HTML\" width=\"396\" height=\"201\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-17.png 396w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-17-300x152.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-17-150x76.png 150w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><\/a><\/p>\n<h2>HTML Internal Links or Local Links<\/h2>\n<p>Internal links are the hyperlinks whose destination lies within the same website or the domain of the website. Their URL is specified relatively i.e., a full URL like <strong>https:\/\/data-flair.training\/<\/strong> is not specified, instead, a relative URL such as headings.html is given.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n &lt;h3&gt;Example Of a link&lt;\/h3&gt; \r\n   &lt;body&gt; \r\n      &lt;p&gt;Click on the following link&lt;\/p&gt; \r\n      &lt;ul&gt;\r\n      &lt;li&gt;&lt;a href = \"headings.html\"&gt;DataFlair Internal Link&lt;\/a&gt; &lt;\/li&gt;\r\n      &lt;li&gt;&lt;a href = \"https:\/\/data-flair.training\/\"&gt;DataFlair External Link&lt;\/a&gt; &lt;\/li&gt;\r\n      &lt;\/ul&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\/06\/pasted-image-0-1-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78798\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-1-6.png\" alt=\"HTML Internal Links\" width=\"350\" height=\"202\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-1-6.png 350w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-1-6-300x173.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-1-6-150x87.png 150w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<h2>Creating Links in HTML<\/h2>\n<p>As we\u2019ve discussed, a link is a connection between the source and destination, specified using the anchor tags. Generally,<\/p>\n<ul>\n<li>An unvisited link is displayed as underlined and blue<\/li>\n<li>A visited link is displayed as purple and underlined<\/li>\n<li>An active link is displayed as red and underlined<\/li>\n<li>Link colors can be changed while hovering also<\/li>\n<\/ul>\n<p>These properties of the link can be easily styled using CSS.<\/p>\n<p>These links are a crucial part of web accessibility. Properly labeled links help users with screen readers understand the context and destination of the links. If the links are visually distinct and properly functional, it improves the user experience, making navigation straightforward.<\/p>\n<p>Links also play a significant role in Search Engine Optimization. Well-placed links can improve a site&#8217;s search engine rankings. Thus, thoughtful linking strategy is essential not just for usability but also for achieving better visibility on search engines<\/p>\n<h2>CSS for links<\/h2>\n<p>CSS properties can be used to style the links in HTML.<\/p>\n<ul>\n<li>To denote an unvisited link, red color has been used.<\/li>\n<li>To denote a visited link, green color has been used.<\/li>\n<li>The link changes to pink color, every time the mouse is passed through it i.e., hovering.<\/li>\n<li>To denote a link that has already been selected, the blue color is used.<\/li>\n<\/ul>\n<p><strong>Code:<\/strong><\/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\/* unvisited link *\/\r\na:link {\r\n  color: red;\r\n}\r\n\r\n\/* visited link *\/\r\na:visited {\r\n  color: green;\r\n}\r\n\r\n\/* mouse over link *\/\r\na:hover {\r\n  color: hotpink;\r\n}\r\n\r\n\/* selected link *\/\r\na:active {\r\n  color: blue;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;ul&gt;\r\n&lt;li&gt;&lt;a href=\"headings.html\"&gt;LINK1&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;a href=\"frames.html\"&gt;LINK2&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;li&gt;&lt;a href=\"elements.html\"&gt;LINK3&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-rotated.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78799\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-rotated.jpg\" alt=\"Hover Link in HTML\" width=\"1644\" height=\"1104\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-rotated.jpg 1644w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-300x201.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-1024x688.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-150x101.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-768x516.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-1536x1031.jpg 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-520x349.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160232-1-1-272x182.jpg 272w\" sizes=\"auto, (max-width: 1644px) 100vw, 1644px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78800\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-scaled.jpg\" alt=\"Select option in Link in HTML\" width=\"2560\" height=\"1788\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-scaled.jpg 2560w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-300x210.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-1024x715.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-150x105.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-768x536.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-1536x1073.jpg 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-2048x1431.jpg 2048w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200525_160222-1-520x363.jpg 520w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<h2>Target Attribute in HTML<\/h2>\n<p>HTML target attribute specifies where the document under the anchor tag should be opened. The options available are-<\/p>\n<ul>\n<li><strong>_blank &#8211;<\/strong> The hyperlink is opened in a new window or tab.<\/li>\n<li><strong>_self &#8211;<\/strong> The hyperlink is opened in the same window or tab.<\/li>\n<li><strong>_top &#8211;<\/strong> The hyperlink is opened in the full body of the window.<\/li>\n<li><strong>_parent &#8211;<\/strong> The hyperlink is opened in the frame of the parent.<\/li>\n<li><strong>framename &#8211;<\/strong> The hyperlink is opened in the frame whose name has been mentioned.<\/li>\n<\/ul>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n&lt;body&gt;   \r\n&lt;h2&gt;The Target Attribute&lt;\/h2&gt;   \r\n&lt;p&gt;Target attribute set to \"_blank\",  \r\nOpens in a new browser window or tab.&lt;\/p&gt; \r\n&lt;a href=\"https:\/\/data-flair.training\/\" target=\"_blank\"&gt;DataFlair&lt;\/a&gt;    \r\n&lt;p&gt;Target attribute set to \"_self\",  \r\nOpens in the same window or tab.&lt;\/p&gt; \r\n&lt;a href=\"https:\/\/data-flair.training\/\" target=\"_self\"&gt;DataFlair&lt;\/a&gt;    \r\n&lt;p&gt;Target attribute set to \"_top\",  \r\nOpens in the full body of the window.&lt;\/p&gt; \r\n&lt;a href=\"https:\/\/data-flair.training\/\" target=\"_blank\"&gt;DataFlair&lt;\/a&gt;    \r\n&lt;p&gt;Target attribute set to \"_parent\",  \r\nOpens in the parent frame.&lt;\/p&gt; \r\n&lt;a href=\"https:\/\/data-flair.training\/\" target=\"_blank\"&gt;DataFlair&lt;\/a&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\/06\/pasted-image-0-2-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78801\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7.png\" alt=\"HTML target Attribute\" width=\"783\" height=\"464\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7.png 783w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7-300x178.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7-150x89.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7-768x455.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-2-7-520x308.png 520w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><\/a><\/p>\n<h2>Use of Base Path in HTML<\/h2>\n<p>The &lt;base&gt; tag within the &lt;head&gt; of an HTML document can be used to provide a default base path for all the links within the web-page. The links contain the relative paths which are concatenated with the base paths to specify the full URL. For example,<\/p>\n<p><strong>Code:<\/strong><\/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;title&gt;DataFlair&lt;\/title&gt;\r\n  &lt;base href = \"https:\/\/data-flair.training\/\"&gt;\r\n   &lt;\/head&gt;\r\n   &lt;body&gt;\r\n    &lt;p&gt;Click on the following link&lt;\/p&gt;\r\n    &lt;a href = \"\/success-stories\/\" target = \"_blank\"&gt;Success Stories&lt;\/a&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\/06\/pasted-image-0-3-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78802\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-3-5.png\" alt=\"HTML BAse path\" width=\"463\" height=\"155\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-3-5.png 463w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-3-5-300x100.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-3-5-150x50.png 150w\" sizes=\"auto, (max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<h2>HTML Image Link<\/h2>\n<p>An image can also be used as a link, i.e., on clicking the image, the control will be redirected.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt; \r\n&lt;body&gt;   \r\n&lt;h1&gt;Using Image as a link&lt;\/h1&gt;   \r\n&lt;p&gt;Click on the image to visit DataFlair.&lt;\/p&gt;  \r\n&lt;a href=\"https:\/\/data-flair.training\/\"&gt; \r\n  &lt;img src=\"DataFlair.png\" alt=\"DataFlair\" \r\nstyle=\"width:500px;height:500px; border: solid;\"&gt; \r\n&lt;\/a&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\/06\/pasted-image-0-4-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78803\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-4-5.png\" alt=\"HTML Image Link\" width=\"671\" height=\"808\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-4-5.png 671w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-4-5-249x300.png 249w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-4-5-125x150.png 125w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-4-5-520x626.png 520w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/a><\/p>\n<h2>HTML Button Link<\/h2>\n<p>Button can be used as a link by using a JavaScript code that would specify where the control should be redirected once the button has been clicked.<\/p>\n<p><strong>Code:<\/strong><\/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\nbutton {\r\n  background-color: #008CBA;\r\n  border: solid;\r\n  color: white;\r\n  padding: 15px 32px;\r\n  text-align: center;\r\n  text-decoration: none;\r\n  display: inline-block;\r\n  font-size: 16px;\r\n  width: 500px;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;   \r\n&lt;button onclick=\"document.location = 'headings.html'\"&gt;DataFlair&lt;\/button&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\/06\/pasted-image-0-5-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78804\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-5-3.png\" alt=\"html button link\" width=\"619\" height=\"61\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-5-3.png 619w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-5-3-300x30.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-5-3-150x15.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-5-3-520x51.png 520w\" sizes=\"auto, (max-width: 619px) 100vw, 619px\" \/><\/a><\/p>\n<h2>HTML Link Title<\/h2>\n<p>Link title can be used to display extra information related to a particular link. It is displayed as tooltip text, every time the mouse is hovered over the link.<\/p>\n<p><strong>Code:<\/strong><\/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;\/head&gt;\r\n&lt;body&gt;   \r\n&lt;a href=\"https:\/\/data-flair.training\/\" title=\"Go to DataFlair\"&gt;DataFlair E-learning&lt;\/a&gt;\r\n&lt;\/body&gt; \r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78809\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112.jpg\" alt=\"html link title\" width=\"1786\" height=\"531\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112.jpg 1786w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-300x89.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-1024x304.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-150x45.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-768x228.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-1536x457.jpg 1536w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/20200530_201112-520x155.jpg 520w\" sizes=\"auto, (max-width: 1786px) 100vw, 1786px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>HTML Download Link<\/h2>\n<p>Links can be provided to download a particular file. For this, mention the name of the file to be downloaded in the href.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt;      \r\n&lt;h3&gt;Download link&lt;\/h3&gt;   \r\n&lt;body&gt; \r\n&lt;a href = \"0801CS171064_0801CS171080.pdf\"&gt;Download PDF File&lt;\/a&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\/06\/pasted-image-0-6-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78805\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-6-3.png\" alt=\"html download link\" width=\"359\" height=\"140\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-6-3.png 359w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-6-3-300x117.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-6-3-150x58.png 150w\" sizes=\"auto, (max-width: 359px) 100vw, 359px\" \/><\/a><\/p>\n<h2>HTML External Paths<\/h2>\n<p>Paths can be mentioned using the full URL or what is relative to the website. For example,<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;!DOCTYPE html&gt; \r\n&lt;html&gt;       \r\n&lt;body&gt;\r\n&lt;p&gt;Full URL&lt;\/p&gt; \r\n&lt;a href=\"https:\/\/data-flair.training\/\"&gt;FULL&lt;\/a&gt;\r\n&lt;p&gt;Same folder within the same website&lt;\/p&gt;\r\n&lt;a href=\"C:\\Users\\shreya\\Desktop\\DATAFLAIR\\frames.html\"&gt;Entire location&lt;\/a&gt;\r\n&lt;p&gt;Same folder&lt;\/p&gt;\r\n&lt;a href=\"frames.html\"&gt;Same Folder&lt;\/a&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\/06\/pasted-image-0-7-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78806\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-7-3.png\" alt=\"html external paths\" width=\"479\" height=\"302\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-7-3.png 479w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-7-3-300x189.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-7-3-150x95.png 150w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/a><\/p>\n<h2>HTML Link 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 are useful in HTML. For example,<\/p>\n<p><strong>Code:<\/strong><\/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\/06\/pasted-image-0-8-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78807\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-8-3.png\" alt=\"html bookmark links\" width=\"277\" height=\"826\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-8-3.png 277w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-8-3-101x300.png 101w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/pasted-image-0-8-3-50x150.png 50w\" sizes=\"auto, (max-width: 277px) 100vw, 277px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>Links in an HTML document are of great importance since they help in redirection of control and avoidance of a large amount of content on a single web-page. In this article, we\u2019ve looked at the basics of HTML links and their attributes such as href, target, and title. We\u2019ve discussed the styling of links and how to use an image and a button as a link. We\u2019ve also seen the use of bookmarks in HTML documents and how to create links for download.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Links, predominantly, are used to link various web-pages or HTML documents with each other. In other words, it is a connection between the source and the destination. These links are often referred to as&#46;&#46;&#46;<\/p>\n","protected":false},"author":10,"featured_media":78796,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22400],"tags":[22474,22473,22472,22471],"class_list":["post-78650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html","tag-html-button-link","tag-html-image-link","tag-html-link-tag","tag-html-links"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create HTML Links and Hyperlinks to Connect Web Pages - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about HTML Links with Examples - Internal Links, How to create links in HTML, CSS for links,Target Attribute, Base path, Image Link, Button link, etc\" \/>\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-links-and-hyperlinks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create HTML Links and Hyperlinks to Connect Web Pages - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about HTML Links with Examples - Internal Links, How to create links in HTML, CSS for links,Target Attribute, Base path, Image Link, Button link, etc\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/\" \/>\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-06-29T03:30:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-26T07:49:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.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=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create HTML Links and Hyperlinks to Connect Web Pages - DataFlair","description":"Learn about HTML Links with Examples - Internal Links, How to create links in HTML, CSS for links,Target Attribute, Base path, Image Link, Button link, etc","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-links-and-hyperlinks\/","og_locale":"en_US","og_type":"article","og_title":"Create HTML Links and Hyperlinks to Connect Web Pages - DataFlair","og_description":"Learn about HTML Links with Examples - Internal Links, How to create links in HTML, CSS for links,Target Attribute, Base path, Image Link, Button link, etc","og_url":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-06-29T03:30:56+00:00","article_modified_time":"2024-07-26T07:49:09+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/a90b082e16aa38d207212d22b0581f33"},"headline":"Create HTML Links and Hyperlinks to Connect Web Pages","datePublished":"2020-06-29T03:30:56+00:00","dateModified":"2024-07-26T07:49:09+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/"},"wordCount":791,"commentCount":6,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg","keywords":["html button link","html image link","html link tag","html links"],"articleSection":["HTML Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/","url":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/","name":"Create HTML Links and Hyperlinks to Connect Web Pages - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg","datePublished":"2020-06-29T03:30:56+00:00","dateModified":"2024-07-26T07:49:09+00:00","description":"Learn about HTML Links with Examples - Internal Links, How to create links in HTML, CSS for links,Target Attribute, Base path, Image Link, Button link, etc","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/06\/Links-in-HTML.jpg","width":1200,"height":628,"caption":"HTML Links"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/html-links-and-hyperlinks\/#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":"Create HTML Links and Hyperlinks to Connect Web Pages"}]},{"@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\/78650","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=78650"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78650\/revisions"}],"predecessor-version":[{"id":142934,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/78650\/revisions\/142934"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/78796"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=78650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=78650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=78650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}