{"id":2622,"date":"2020-10-26T04:05:23","date_gmt":"2020-10-26T09:05:23","guid":{"rendered":"https:\/\/cssnewbie.com\/?p=2622"},"modified":"2020-10-26T04:05:23","modified_gmt":"2020-10-26T09:05:23","slug":"how-to-add-links-in-css","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/how-to-add-links-in-css\/","title":{"rendered":"How To Add Links In CSS"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2623 size-large\" src=\"https:\/\/cssnewbie.com\/wp-content\/uploads\/2020\/10\/64621-1024x745.jpg\" alt=\"How To Add Links In CSS\" width=\"1024\" height=\"745\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>We generally add links in between the text on a webpage which in an actual sense creates a web and we get WorldWideWeb, right? <a href=\"http:\/\/www.garlikov.com\/teaching\/hyperlinks.htm\">Garlikov<\/a> explains how links can be used to relate various ideas and set the navigation for different topics.<\/p>\n<p>No wonder, <a href=\"https:\/\/link.springer.com\/chapter\/10.1007\/978-3-211-93971-0_26\">Springer<\/a> calls links the \u201cessence\u201d of the online web.<\/p>\n<p>Now, in this article, we will learn ways to add one or more links. We will also learn how to style and decorate the link, create a button around the link and distinguish the link based on hover effect, or link which has been opened once by the user.<\/p>\n<p>We will begin with a simple code where we shall add two links and differentiate it with two different colors. The CSS id as an attribute to &lt;a&gt; tag will help us reach there.<\/p>\n<p>Let\u2019s check the code and then discuss it.<\/p>\n<p>Code:<\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n  &lt;title&gt; How to add links in CSS &lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n\nThe following two links have different colors because of CSS\n\n&lt;p&gt; &lt;strong&gt; &lt;a href=\"https:\/\/www.inserthtml.com\"&gt;\u00a0 Learn HTML with article type tutorials &lt;\/a&gt;\n&lt;br&gt;\n&lt;a href=\"https:\/\/cssnewbie.com\" id=\"check\"&gt; Learn CSS styling with articles &lt;\/a&gt;\n  &lt;\/strong&gt;\n&lt;\/p&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>CSS File:-<\/p>\n<pre>a {\n  color: blue;\n}\n#check{\n  color:red;\n  }<\/pre>\n<p>Here&#8217;s what the output will be:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2624 size-large\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2020\/10\/TwoLinks-1024x266.png\" alt=\"How To Add Links In CSS\" width=\"1024\" height=\"266\" \/><\/p>\n<p>The property <em>color <\/em>has been used in the CSS file to add and change the color of the link. It should be used to differ the link from the rest of the text and help the user to navigate to a page. Such link building also drives traffic or can be used to create a sales funnel which is a well-planned chain of web pages to drive a customer.<\/p>\n<p>Moving on, we will learn about four states of any link.<\/p>\n<ol>\n<li>a: link<\/li>\n<li>a:visited<\/li>\n<li>a:hover<\/li>\n<li>a:active<\/li>\n<\/ol>\n<p>The first state is how the link is displayed on a webpage. The second state is the action on the link like changing the color of it once it has been visited. The third state changes the color or shows an underlined text when the cursor moves over it and the last state is when the link is finally clicked.<\/p>\n<p>Remember not to change the sequence of these states is equally important and should be followed each time. I would encourage you to copy-paste the code on <a href=\"https:\/\/codepen.io\/\">CodePen<\/a> as the output is responsive.<\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n  &lt;title&gt; How to add links in CSS &lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n&lt;p&gt; &lt;strong&gt; &lt;a href=\"https:\/\/cssnewbie.com\" target=\"_blank\"&gt; \u00a0Hover over me to change the color to green\u00a0 &lt;\/a&gt; &lt;\/strong&gt; &lt;\/p&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/pre>\n<p>CSS Filename:<\/p>\n<p>&nbsp;<\/p>\n<pre>a{\n  font-size: 50px;\n}\na:link {\n  color: grey;\n}\n\na:visited {\n  color: lightblue;\n}\n\na:hover {\n  color: green;\n}\n\na:active {\n  color: violet;\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3>Link Buttons<\/h3>\n<p>The links can be converted into buttons which can be colorful enough to compel the reader to tap it. This is especially helpful when you are creating a \u2018Call To Action\u2019 and want to drive your website visitors to that button.<\/p>\n<p>To achieve this we use properties like <em>padding, background-color, and text-decoration.<\/em> In the following code, we have used these properties where text-decoration value is none for the first two states and underline for hover which again gives a response to the reader.<\/p>\n<p>The size of the button shape visible can be altered with the help of <em>padding<\/em>. Let\u2019s check the code and explore it further <a href=\"https:\/\/codepen.io\/trending\">here<\/a>.<\/p>\n<pre>&lt;html&gt;\n&lt;head&gt;\n  &lt;title&gt; How to add links in CSS &lt;\/title&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n&lt;h1&gt; Buttons of links &lt;\/h1&gt;\n&lt;p&gt; The following button will take you to learn CSS and the button helps in highlighting &lt;\/p&gt; &lt;br&gt;\n&lt;a href=\"https:\/\/cssnewbie.com\"&gt; Learn CSS &lt;\/a&gt;\n&lt;\/body&gt;\n\n&lt;\/html&gt;<\/pre>\n<p>CSS File:<\/p>\n<pre>a:link, a:visited {\n  background-color: green;\n  color: lightblue;\n  padding: 18px 64px;\n  text-align: center;\n  text-decoration: none;\n}\n\na:hover{\n  text-decoration: underline;\n  background-color: blue;\n}\n\na:active {\n  background-color: red;\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>Here&#8217;s how the output will be:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-2625 size-large\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2020\/10\/LInkButtons-1024x271.png\" alt=\"How To Add Links In CSS\" width=\"1024\" height=\"271\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Conclusion<\/h3>\n<p>In this guide, we learned how to add links in CSS. We also learned different kinds of links and different states of links.<\/p>\n<p>Links are an essential part of the World Wide Web, and if used correctly by a web developer it can help drive traffic.<\/p>\n<p>To learn such other CSS techniques, subscribe to our <a href=\"http:\/\/www.cssnewbie.com\">blog<\/a>!<\/p>\n<p>To see how to add forms in CSS, visit our previous article!<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<\/p>\n<p>&nbsp;<\/p>\n<p>We generally add links in between the text on a webpage which in an actual sense creates a web and we get WorldWideWeb, right? Garlikov explains how links can be used to relate various ideas and set the navigation for [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/how-to-add-links-in-css\/\" title=\"Click to read 'How To Add Links In CSS'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[168],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2622"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=2622"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/2622\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=2622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=2622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=2622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}