Site logo

Archived topic

CSS to underline H2 and H3 titles

3 replies · Started by William on August 25, 2021

Viewing posts 1–4 of 4

Hi there,

you can limit the scope of your link styles to just the elements they sit within, this will stop it from appearing on things like buttons and images eg. this applies to all links in P, H2 and H3

.entry-content p a,
.entry-content h2 a,
.entry-content h3 a {
    font-weight: 900;
    transition: color 100ms;
    box-shadow: inset 0 -14px 0 #bdff67;
}

.entry-content p a:hover,
.entry-content h2 a:hover,
.entry-content h3 a:hover {
    background-color: #bdff67;
}

If you want to include underline styles to NON linked headings then you can include them too eg.:

.entry-content p a,
.entry-content h2 a,
.entry-content h3 a,
.entry-content h2,
.entry-content h3  {
    font-weight: 900;
    transition: color 100ms;
    box-shadow: inset 0 -14px 0 #bdff67;
}

David as always, thank you for coming through with such elegant CSS. This is tremendously helpful.

You're most welcome - glad to be of help!

This archived topic is closed to new replies.