<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Brent Larson</title>
    <description>The latest articles on DEV Community by Brent Larson (@nerdcowboy).</description>
    <link>https://dev.to/nerdcowboy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F465311%2F1e5a0475-2d44-4cf6-bfe0-6f02190fb445.jpg</url>
      <title>DEV Community: Brent Larson</title>
      <link>https://dev.to/nerdcowboy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nerdcowboy"/>
    <language>en</language>
    <item>
      <title>5 ways to make sliding underlined links</title>
      <dc:creator>Brent Larson</dc:creator>
      <pubDate>Sat, 12 Sep 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/nerdcowboy/5-ways-to-make-sliding-underlined-links-1fi0</link>
      <guid>https://dev.to/nerdcowboy/5-ways-to-make-sliding-underlined-links-1fi0</guid>
      <description>&lt;p&gt;Underlined links are as old as the web itself. The underline gives affordance to users that it will link somewhere else. By default, all links are underlined and that's good enough for a lot of websites.&lt;/p&gt;

&lt;p&gt;However, adding a little bit of motion to an underline can create a delightful micro-animation that can help bring your website to life. (did I buzzword right?)&lt;/p&gt;

&lt;h2&gt;
  
  
  Recreating the underline
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tk8XE2Ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/606d4ea98876f91c03eddf5f62ead254/1f083/basic-underline.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tk8XE2Ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/606d4ea98876f91c03eddf5f62ead254/1f083/basic-underline.png" alt="Example of basic underline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before we dive into the underline transitions, first we need to re-create the native anchor underline.&lt;/p&gt;

&lt;p&gt;To get started, we'll add color to the link to help denote that it's a link and we'll get rid of the native underline so we can set our own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From here, we could use an absolutely positioned pseudo-element (i.e. &lt;code&gt;::before&lt;/code&gt;) to achieve the same effect we want. However, absolute positioning will only display an underline on a single line, so I can't recommend going that route unless you're using this for something that you're confident won't ever be more than a single line.&lt;/p&gt;

&lt;p&gt;So the only other option for creating a multi-line underline is using the &lt;code&gt;background&lt;/code&gt; property. Since you can't change the size or positioning of &lt;code&gt;background-color&lt;/code&gt;, we need to use &lt;code&gt;background-image&lt;/code&gt;. I repeat the same color in the gradient as I'm trying to make the background a solid color, but you can definitely spice things up by making it a real gradient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the gradient set, it will make the entire anchor's background to the color/gradient we specify, so we'll need to change its size and position to make it look like an underline.&lt;/p&gt;

&lt;p&gt;We'll set the &lt;code&gt;background-size&lt;/code&gt;'s width to &lt;code&gt;100%&lt;/code&gt; and the height to &lt;code&gt;0.1em&lt;/code&gt;—we use an em here as it will proportionally scale the underline if the text size changes.&lt;/p&gt;

&lt;p&gt;Set &lt;code&gt;background-position-y&lt;/code&gt; to &lt;code&gt;100%&lt;/code&gt; to place the underline to the bottom of the anchor, making it look like an underline.&lt;/p&gt;

&lt;p&gt;We'll also throw a transition in there so we can animate our underlines later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/MWyOxOY"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Slide in and back
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q06qpt6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/6b1581f30a02ff871944087d1fb58d3b/slide-in-back.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q06qpt6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/6b1581f30a02ff871944087d1fb58d3b/slide-in-back.gif" alt="Example of slide in and back underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this effect, we're going to be creating a link that underlines from left to right on hover. When hovered off, the underline will slide back to the left and disappear.&lt;/p&gt;

&lt;p&gt;We set the &lt;code&gt;background-size&lt;/code&gt; width to &lt;code&gt;0%&lt;/code&gt; initially to hide it. On hover, we change it to &lt;code&gt;100%&lt;/code&gt; to get it to slide from left to right.&lt;/p&gt;

&lt;p&gt;If you want to reverse the direction, change &lt;code&gt;background-position-x&lt;/code&gt; to &lt;code&gt;100%&lt;/code&gt; to change the starting position to the right.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/jOqqxpG"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Slide middle out
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P0FvO6h_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/a0b1d502429298b617e704172c3070df/slide-middle-out.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P0FvO6h_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/a0b1d502429298b617e704172c3070df/slide-middle-out.gif" alt="Example of slide middle out underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we hover on the link with this effect, the line starts from the middle and extends simultaneously to the right and left edges. On hover-off, the line slides back to the middle and disappears.&lt;/p&gt;

&lt;p&gt;The only difference between this one and the previous one is that we change &lt;code&gt;background-position-x&lt;/code&gt; to &lt;code&gt;50%&lt;/code&gt; to making the starting point of the underline in the middle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/abNNKZe"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Slide in and out
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lTIvRnYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/d7bf1ce75390c8f94befe5874879092a/slide-in-out.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lTIvRnYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/d7bf1ce75390c8f94befe5874879092a/slide-in-out.gif" alt="Example of slide in and out underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hovering on a link with this effect looks exactly the same as the first effect. However, on hover-off, the underline will slide off to the right instead of snapping back to the left.&lt;/p&gt;

&lt;p&gt;There's no hover-off pseudo-class in CSS, unfortunately, but there are some &lt;a href="https://css-tricks.com/different-transitions-for-hover-on-hover-off/"&gt;CSS tricks to mimic it for certain effects&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We essentially use the same CSS trick, but here we take advantage of the underline not being initially visible. We set &lt;code&gt;background-position-x: 100%&lt;/code&gt; with our initial styles so it slides to the right on hover-off and change it to &lt;code&gt;0%&lt;/code&gt; on hover so that the line comes in from the left.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/QWNNrzq"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Slide to middle
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nD8dfp2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/8d3f4dce3e13cad05ef7e6d4bcb8aed1/slide-to-middle.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nD8dfp2O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/8d3f4dce3e13cad05ef7e6d4bcb8aed1/slide-to-middle.gif" alt="Example of slide to middle underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this effect, we have 2 lines that we start on the outside edges and slide them inwards until they meet in the middle. On hover-off, they slide off to the edges and disappear.&lt;/p&gt;

&lt;p&gt;Since we have 2 different lines, we need to create 2 linear-gradients. Anytime you want to add another background property, you must add a comma after each item's value. However, if the value is identical for both, CSS will just repeat it. This means we don't have to manually duplicate each background property if it's going to be the same for each linear-gradient.&lt;/p&gt;

&lt;p&gt;Since everything else for the lines are the same, we just need to adjust their positions. We set the first line's &lt;code&gt;background-position-x&lt;/code&gt; to &lt;code&gt;0%&lt;/code&gt; to start it on the left edge and the 2nd to &lt;code&gt;100%&lt;/code&gt; to start it on the right edge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/poydBwR"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Always-visible underline variants
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MgDlQrRc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/033433ba78735e149729d152f525c965/sliding-variants.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MgDlQrRc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/033433ba78735e149729d152f525c965/sliding-variants.gif" alt="Example of multi-line slide over the top underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you do want an underline to always be present, you can still use the first four effects. The only difference is we need to add an additional underline using the same &lt;code&gt;linear-gradient&lt;/code&gt; effect. Note that for the slide to middle effect, we'll have to do add a 3rd &lt;code&gt;linear-gradient&lt;/code&gt; since that effect already uses 2 of them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/*
// Shared Styles
*/&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*
// Slide in &amp;amp; back
*/&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slide-in-back&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-back&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-back&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*
// Slide in &amp;amp; out
*/&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-out&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slide-in-out&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-out&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-in-out&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*
// Slide middle out
*/&lt;/span&gt;
&lt;span class="nc"&gt;.slide-middle-out&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slide-middle-out&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-middle-out&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-middle-out&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*
// Slide to middle
*/&lt;/span&gt;
&lt;span class="nc"&gt;.slide-to-middle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="m"&gt;#d99a5a&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;saddlebrown&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.slide-to-middle&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-to-middle&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.slide-to-middle&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/qBZZeby"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Slide to top
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8ctnrqZo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/47db69033603428985762fb7e11ec977/slide-to-top.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8ctnrqZo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/47db69033603428985762fb7e11ec977/slide-to-top.gif" alt="Example of slide to top underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this effect, we have an always-visible underline, but on hover, we'll grow the underline to the top of the anchor.&lt;/p&gt;

&lt;p&gt;Since this underline will slide underneath the text, it's important to make sure you use colors that will pass a &lt;a href="https://colourcontrast.cc/"&gt;contrast checker&lt;/a&gt; to ensure good accessibility.&lt;/p&gt;

&lt;p&gt;Since we want the underline to always be visible, note that we changed the default &lt;code&gt;background-size&lt;/code&gt;'s width to &lt;code&gt;100%&lt;/code&gt;. To slide the underline to the top of the link, we change the &lt;code&gt;background-size&lt;/code&gt;'s height to &lt;code&gt;100%&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#d99a5a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;background-position-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;background-size&lt;/span&gt; &lt;span class="m"&gt;0.2s&lt;/span&gt; &lt;span class="n"&gt;ease-in-out&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:focus&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://codepen.io/nerdcowboy/pen/zYqKmBJ"&gt;Edit on CodePen&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fDaBb-UW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/0922f9477ebaef8708d65347a7a85cab/slide-over-top.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fDaBb-UW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/0922f9477ebaef8708d65347a7a85cab/slide-over-top.gif" alt="Example of multi-line slide over the top underline effect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For making it this far, I have a little treat for you. I saw this effect making the rounds on Twitter and it's actually what inspired me to write this post.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/jh3yy"&gt;@jh3yy&lt;/a&gt; created &lt;a href="https://codepen.io/jh3y/pen/gOPjBPM"&gt;a CodePen&lt;/a&gt; where he animates an underline over an existing underline.&lt;/p&gt;

&lt;p&gt;Learn how to create this effect on &lt;a href="https://egghead.io/lessons/css-create-an-animated-underline-effect-using-css-transition-and-css-background-position"&gt;Jhey's Egghead tutorial.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Got more?
&lt;/h3&gt;

&lt;p&gt;Have a cool &lt;em&gt;underline&lt;/em&gt; link effect? I'd love to see it!&lt;/p&gt;

&lt;p&gt;Send it to me &lt;a href="https://twitter.com/nerdcowboy"&gt;@NerdCowboy&lt;/a&gt; or through my &lt;a href="https://nerdcowboy.com/contact"&gt;contact page&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Pretty vs Usable</title>
      <dc:creator>Brent Larson</dc:creator>
      <pubDate>Sat, 12 Sep 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/nerdcowboy/pretty-vs-usable-5bpe</link>
      <guid>https://dev.to/nerdcowboy/pretty-vs-usable-5bpe</guid>
      <description>&lt;h2&gt;
  
  
  Beautiful is Best?
&lt;/h2&gt;

&lt;p&gt;A phenomenon most of us are familiar with, even if we don't know it by name:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;good looking people have an unfair advantage in life.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://en.wikipedia.org/wiki/Physical_attractiveness_stereotype#Beauty_premium_phenomenon"&gt;beauty premium phenomenon&lt;/a&gt; states that we expect good-looking people to be "better, smarter, more successful, more important, and more valuable."&lt;/p&gt;

&lt;p&gt;Likewise, in 1995 when researchers &lt;a href="https://www.researchgate.net/publication/290957555_Apparent_usability_vs_inherent_usability_experimental_analysis_on_the_determinants_of_the_apparent_usability"&gt;were studying ATM UIs&lt;/a&gt;, they noticed that people expected more of and were more forgiving of good-looking interfaces.&lt;/p&gt;

&lt;p&gt;Sound familiar?&lt;/p&gt;

&lt;p&gt;If you replace "UIs" with "people", you basically have what the researchers discovered—the &lt;a href="https://www.nngroup.com/articles/aesthetic-usability-effect/"&gt;aesthetic-usability effect&lt;/a&gt;. It states that we have a tendency to perceive attractive UIs as more usable and expect that they'll work better—even if that isn't true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rationalizing Pretty
&lt;/h2&gt;

&lt;p&gt;It seems almost every UX designer (including yours truly) has cited this aesthetic-usability effect at one point or another to justify a design decision that makes the design better-looking at the expense of usability or clarity.&lt;/p&gt;

&lt;p&gt;And you know what? They're almost always wrong.&lt;/p&gt;

&lt;p&gt;Michal Malewicz says it best in his &lt;a href="https://uxdesign.cc/ux-has-pretty-bad-ux-fd2702e5c22a"&gt;tell it like it is article&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“UX has a hole in it. It’s called UI and it’s quite bad. This is often because a large part of “UX Designers” can’t design. There. I said it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It takes some skill to make a design pretty, but it takes a lot more skill to make a design pretty &lt;em&gt;and&lt;/em&gt; usable.&lt;/p&gt;

&lt;p&gt;The majority of job postings ask UX designers to do both UX &amp;amp; UI design, despite most not being remotely qualified to do both.&lt;/p&gt;

&lt;p&gt;Not that I believe we should only have specialists—quite the contrary. But I don't believe we should expect designers to do something that they haven't shown they're capable of doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Dumb Dichotomy
&lt;/h2&gt;

&lt;p&gt;Designers citing this principle in defense of their "pretty" designs like to come up with this dumb dichotomy: &lt;em&gt;either we make it pretty OR we make it usable.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l1lenkIg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/b05ef2ebeff1fdaa989465b276bc1486/why-not-both.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l1lenkIg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://nerdcowboy.com/b05ef2ebeff1fdaa989465b276bc1486/why-not-both.gif" alt="Why don't we have both? (meme)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Spoiler: you can make something pretty and usable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vsEdnQgo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/1d4c4860efe005b00b57f63dec00fc26/ab233/fb-messenger-icons.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vsEdnQgo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/1d4c4860efe005b00b57f63dec00fc26/ab233/fb-messenger-icons.jpg" alt="Comparison of Facebook Messenger app tab bars with and without icons."&gt;&lt;/a&gt;&lt;br&gt;
Facebook Messenger recently redesigned its mobile app. Even though they simplified their app significantly, one thing they added was labels to their bottom tab bars. Is it cleaner without labels? Certainly. But adding labels doesn't all of a sudden make it an ugly design.&lt;/p&gt;

&lt;h2&gt;
  
  
  No One Knows What Your Dam Icon Means
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lMauB0CV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/116265b66013b2aece19c3cc13f08241/a6d36/dam-icon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lMauB0CV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://nerdcowboy.com/static/116265b66013b2aece19c3cc13f08241/a6d36/dam-icon.png" alt="An icon of a dam"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlabeled icons are probably the number one reason a designer will bring up the aesthetic-usability principle. You can add a label to your dam icon in a way that looks good &lt;strong&gt;and&lt;/strong&gt; people will actually be able to understand that the icon means “dam” and not "bacon dispenser."&lt;/p&gt;

&lt;p&gt;We learned this was a bad idea when Flash became popular (remember &lt;a href="http://www.webpagesthatsuck.com/mysterymeatnavigation.html"&gt;mystery meat navigation?&lt;/a&gt;), but we seem to keep making the same mistakes over and over.&lt;/p&gt;

&lt;p&gt;Unlike art, there's only one correct design interpretation, and it's your job as a designer to make that crystal clear.&lt;/p&gt;

&lt;p&gt;There are certainly instances where you need to make some tradeoffs on aesthetics to make a design more usable, but if the rest of the UI is designed well, then it's still going to get the aesthetic-usability effect bump. It just won't look perfect. But really, how often is anything perfect?&lt;/p&gt;

&lt;p&gt;Even good-looking people have a few flaws.&lt;/p&gt;

</description>
      <category>ux</category>
      <category>design</category>
    </item>
  </channel>
</rss>
