Title: How to get a hover underline to appear above text and have a drop-shadow effect?
Tags: html;css
Question: 

As you can see in the first image, I have the underline appear under the links which covers the red &quot;hr&quot; that runs across the page. I want to apply the same effect on the archives and categories links but with it appearing above.  I can't seem to find a way of doing it.  I looked up a hover underline position, and  tried using text-underline-position to being above but that doesn't do what I want it to do.  How do I go about doing this?
In the second image, in the prototype I had designed to have the underline have a drop-shadow effect.  How do I go about doing that with hover links?  Can it even be achieved if I'm using an image as a background? Or would I need to save that as a .png with transparency? Any tips?
HTML:
```<!DOCTYPE html&gt;
<html&gt;
  <head&gt;
    <title&gt;My Site</title&gt;
    <link rel=&quot;stylesheet&quot; href=&quot;stylesheet.css&quot; type=&quot;text/css&quot; /&gt;
  </head&gt;

  <body&gt;
    <header&gt;</header&gt;

    <div id=&quot;NavSection&quot;&gt;
      <div id=&quot;TopNav&quot;&gt;
        <nav id=&quot;MainNav&quot;&gt;
          <ul id=&quot;Menu&quot;&gt;
            <li&gt;<a href=&quot;&quot;&gt;Home</a&gt;</li&gt;
            <li&gt;<a href=&quot;&quot;&gt;About</a&gt;</li&gt;
            <li&gt;<a href=&quot;&quot;&gt;Contact</a&gt;</li&gt;
          </ul&gt;
        </nav&gt;
      </div&gt;

      <hr /&gt;

      <div id=&quot;SecondNavSection&quot;&gt;
        <nav id=&quot;SecondNav&quot;&gt;
          <ul id=&quot;SecondMenu&quot;&gt;
            <li&gt;<a href=&quot;&quot;&gt;Archives</a&gt;</li&gt;
            <li&gt;<a href=&quot;&quot;&gt;Categories</a&gt;</li&gt;
          </ul&gt;
        </nav&gt;
      </div&gt;

      <div id=&quot;SiteTitle&quot;&gt;
        <h1 id=&quot;My&quot;&gt;My<span id=&quot;Site&quot;&gt;Site</span&gt;</h1&gt;
      </div&gt;
    </div&gt;

    <div id=&quot;ContentDiv&quot;&gt;
      <main id=&quot;ContentSection&quot;&gt;
        <div id=&quot;Content&quot;&gt;
          <p&gt;Content goes here.</p&gt;
        </div&gt;
      </main&gt;
    </div&gt;

    <footer&gt;
      <p&gt;My Site</p&gt;
    </footer&gt;
  </body&gt;
</html&gt;

```
CSS:
```body {
  background-color: #ffffff;
  background: url(/images/background.jpg) no-repeat center center fixed;
  background-size: cover;
  resize: both;
  overflow: scroll;
  overflow-x: hidden;
}
181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16-webkit-scrollbar {
  width: 0px;
  font-family: Arial;
}

@font-face {
  font-family: ubuntu-medium;
  src: url(/fonts/ubuntu-medium.ttf);
}

/* @media (max-width:3440px){
  body{background: url(/images/background.jpg) no-repeat center center fixed;}
} */

/* @media (min-width:480px){
  body{background: url(/images/background.jpg) no-repeat center center fixed;}
} */

#NavSection {
  margin-top: 3%;
}

#MainNav {
  position: left;
  margin-left: 11%;
}

#Menu li {
  font-family: ubuntu-medium;
  font-weight: normal;
  color: #414141;
  padding: 0px 10px;
  display: inline;
  font-size: 15px;
  list-style-type: none;
}

#Menu a:hover {
  text-decoration-color: #414141;
  text-underline-offset: 0.12em;
  text-decoration-line: underline;
  text-decoration-style: solid;
  text-decoration-thickness: 4px;
}

hr {
  margin: 0px;
  border: 2px solid red;
  width: auto;
}

a {
  color: #414141;
  text-decoration: none;
}

a:active {
  color: #ff0000;
}

#SiteTitle {
  margin-left: 0%;
}

#My {
  font-family: Impact;
  font-weight: normal;
  font-size: 30px;
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: #414141;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.08em;
}

#Site {
  color: red;
}

ul {
  list-style-type: none;
  margin-top: 0px;
  margin-bottom: 0px;
  padding: 0px;
}

#SecondNav {
  float: right;
  font-family: ubuntu-medium;
  font-weight: normal;
  color: #414141;
  padding: 0px 10px;
  font-size: 15px;
  margin-right: 11%;
}

#SecondMenu a:hover {
  margin-bottom: 5px;
  text-decoration-line: underline;
  text-underline-position: above;
  text-decoration-style: solid;
  text-decoration-color: #414141;
  text-decoration-thickness: 4px;
}

#SecondMenu li {
  margin-bottom: 5px;
  font-family: ubuntu-medium;
  font-weight: normal;
  color: #414141;
  padding: 0px 10px;
  display: inline;
  font-size: 15px;
  list-style-type: none;
}

#ContentDiv {
  width: 70%;
  height: 40%;
  position: absolute;
  top: 30%;
  left: 15%;
  transform: translateX(0%);
  background-color: rgba(255, 0, 0, 0.4);
}

#ContentSection {
  width: 90%;
  height: 60%;
  position: absolute;
  top: 20%;
  left: 5%;
  background-color: rgba(255, 255, 255, 0.9);
}

#Content {
  margin: 3%;
}
```

Comment: Post your CSS and HTML of the above pictures.

Comment: Wrap the link in a div and prepend a div on top that is just a solid rect.


Here is another answer: Using two lists and using border on the li you can get the color.


```.navbar {
  position: relative;
  margin-bottom: 5px;
  font-family: ubuntu-medium;
  font-weight: normal;
}

.navbar a { 
  text-decoration: none;
  color: #414141;
}

.navbar ul {
    display: flex;
    margin: 0;
    padding: 0;
}
.navbar ul li {
    display: block;
    flex: 0 1 auto; /* Default */
    list-style-type: none;
    line-height: 2.5em;
    margin-left: 1em;
}

.sub ul {
  justify-content: flex-end;
}

.navbar181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16ore{
  position: absolute;
  z-index: -1;
  margin-top: 2.5em;
  content: '';
  border-top: 10px solid #FF0000;
  width:100%;
}


.main li.active {
  border-bottom: 10px solid #000000;
  box-shadow: 0 4px 2px -2px #AAAAAA;
}

.sub li.active {
  border-top: 10px solid #000000;
  margin-top: -10px;
  box-shadow: 0px -4px 2px -2px #AAAAAA;
}```
```<div class="navbar"&gt;
  <nav class="main"&gt;
    <ul&gt;
      <li&gt;<a href="#" class="active"&gt;Home</a&gt;</li&gt;
      <li class="active"&gt;<a href="#"&gt;About</a&gt;</li&gt;
      <li&gt;<a href="#"&gt;Contact</a&gt;</li&gt;
    </ul&gt;
  </nav&gt;
  <nav class="sub"&gt;
    <ul&gt;
      <li class="active"&gt;<a href="#"&gt;Foo</a&gt;</li&gt;
      <li&gt;<a href="#"&gt;Bar</a&gt;</li&gt;
      <li&gt;<a href="#"&gt;Baz</a&gt;</li&gt;
    </ul&gt;
  </nav&gt;
</div&gt;```





Here is another answer: Use this
HTML code
```<div class=&quot;menu&quot;&gt;
<a href=&quot;#&quot;&gt;A</a&gt;
<a href=&quot;#&quot;&gt;B</a&gt;
<a href=&quot;#&quot;&gt;C</a&gt;
<a href=&quot;#&quot;&gt;D</a&gt;
<a href=&quot;#&quot;&gt;E</a&gt;
<a href=&quot;#&quot;&gt;F</a&gt;
</div&gt; 
```
CSS
```    .body {
     background:#222; 
     padding:50px;
     }

    .menu {  
    margin:0 auto; 
    with 90%;
    }

    .menu a {
    display:block; 
    float: left; 
    padding:5px 0;
    color:#fff; 
    text-decoration:none;
    margin:0 10px; font-family:arial;
    }

   .menu a:hover { 
    border-bottom:3px solid #fff;
    }
```
Hope gonna help you, also i would be glad if you rate my comment good!


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:02/09/21', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<html><css>', 'Title': 'How to get a hover underline to appear above text and have a drop-shadow effect?', 'ViewCount': 223, 'id': 66128817, 'user_AboutMe': '', 'user_AccountId': 20455161.0, 'user_DisplayName': 'VitaminD', 'user_Reputation': 33.0, 'user_Views': 5.0, 'user_id': 15009008.0}}