Adding underlines to link

hello, I would like to add an underline to the links my posts. I have put some code into global CSS but it shows up on pages as well, how can I get it to just show on my posts. The other thing is I dont want the text in my buttons to be underlined on the posts, so I basically want to selectively apply the underlined to different links on a post.

So I assume that would mean setting up a class and then selectively applying it to links, can you tell me how I would do that, thanks.

Hi @waynepatt58,

thanks for writing in!

You can do this by taking body class as your parent CSS selector.
For example, Blog page having its unique class in body tag that is body.blog and for single post page that is body.single-post if you target these two classes as parent class then it will only apply to Blog or single post page.

EX

body.blog .entry-content a, body.single-post .entry-content a {
text-decoration: underline;
}

/*if you want to remove underline from buttons inside entry content* add this*/

body.blog .entry-content .x-btn, body.single-post .entry-content .x-btn {
text-decoration: none !important;
}

Hope this helps!

If you would like to learn CSS, I am sharing few resources that you take a look to get started with CSS and an interesting tool that you can use to speed up the development process.

I recommend you to watch following video that will help you to get started with CSS.

https://www.youtube.com/watch?v=MFR4WXiLzpc

Sometimes it can get a bit difficult to find out the right selector to be able to write the required CSS codes. A handy tool that can help you in this is Google Chrome dev tools. I am sharing the resource that you can refer to get started with dev tools.

https://developers.google.com/web/tools/chrome-devtools/css/

https://developers.google.com/web/tools/chrome-devtools/

https://www.youtube.com/watch?v=tP_kXBJWPhQ&t=200s

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.