34
loading...
This website collects cookies to deliver better user experience
Nav
link at the header, there will be a nice yellow highlight appear below the link. This is cool, tho .a
tag, they used text-decoration
stuff.text-decoration
stuff, the second one is using the old border-bottom
trick.personally, I prefer text-decoration
over border-bottom
. The right tool for the right job. I donno.
text-decoration
is the most straightforward way to underline text.a {
text-decoration: none;
color: blue;
}
/* show underline on hover */
a:hover {
text-decoration: underline;
text-decoration-color: red;
-webkit-text-decoration-color: red;
}
note: -webkit
is for Safari.
This is the only thing you needed. If you want to customize more, read more :P
text-decoration
works fine by itself, but you can add a few properties to customize the way it looks:text-decoration-color
lets you change an underline’s color separately from its text color.g
, p
, f
. It didn't go through it. Examples :text-decoration-style
give you a free underline design using different values. No need to add SVG.dashed
dotted
double
solid
wavy
note: This example is from Mozilla MDN. You also can seperate the text-decoration
into text-decoration-color
and text-decoration-style
.
a {
text-decoration: underline;
text-decoration-color: red;
text-decoration-style: wavy;
}
disclaimer: if you happy with the first trick, just go with it. This is just another same trick.
border-bottom
trick, first we need to remove the underline with the text-decoration
property value of none
. Then we add the border-bottom
property with 3 short-hand CSS values of 3px solid red
.3px
= Variable of the underline width in pixelssolid
= Border style (solid, dotted, or dashed)red
= Color code. Hex also can, like #999999
a
tag or any link-related tag.