Wallace Mogerty Wallace Mogerty - 2 months ago 14
HTML Question

Indent Hyperlinks that are Same Line

I have three hyperlinks that are displayed on the same line and I would like to shift all three links to the right by a specified number of pixels. Below is my code, I have tried text-indent and it is not working...



nav a {
background-color: #ccff99;
color: #333333;
border-style: solid;
border-color: #333333;
border-width: 1px;
text-decoration: none;
font-weight: bold;
text-indent: 20px;
}

<nav>
<a href="#">Home</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</nav>




Answer Source

Try something like this:

nav a {
  background-color: #ccff99;
  color: #333333;
  border-style: solid;
  border-color: #333333;
  border-width: 1px;
  text-decoration: none;
  font-weight: bold;
  text-indent: 20px;
}

nav a:first-child {
  margin-left: 20px;
}
<nav>
  <a href="#">Home</a>
  <a href="#">Services</a>
  <a href="#">Contact</a>
</nav>