

Removing trailing space underlines from groups of anchor tags
source link: https://dev.to/cassidoo/removing-trailing-space-underlines-from-groups-of-anchor-tags-54ib
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Recently as I was working on some styles for my blog, I ran into an issue where I had a block of anchor tags rendered in JSX, and they didn't look right.
All of the links had trailing spaces, and those spaces were being underlined!
How did we get here?
I had an array of tags, and they were being displayed in a <div>
, like so:
<div>
{
tags.map((tag) => (
<a class="tag" href={`#`}>
#{tag}
</a>
))
}
</div>
I didn't fully understand why the underlined, trailing space was being rendered, and weeped as the gods of JavaScript mocked me.
After getting over it, I tried changing the word-wrap
and other various CSS styles to fix the links, with no success. I admit it took me way longer than I expected to find a solution, and I wrote this blog to save me from my future self who will inevitably run into this problem again.
How did we overcome?
Turns out, if you add display: inline-block
, it removes the underlines in the spaces!
Here's a CodePen to show this lil CSS trick in action!
The end, stay safe, nerds.
Recommend
-
54
It’s a cool little effect. The default link style has an underline (which is a good idea) and then on :hover you see the underline essentially thicken up turning into almost what it would have looked liked if you...
-
6
Animated Multiline Link Underlines with CSS Updated on January 29, 2019 · Published on December 19, 2018614 words · ~3 minutes to read One benefit of building my
-
3
YouTube Underlines Its Value for Musicians as TikTok Continues to Rise Published June 2, 2021 By
-
8
Removing trailing characters from SAS strings 0
-
4
Removing unwanted space between images advertisements My problem is in my navigation bar, which can be found here:
-
5
Snapchat's Latest Viral AR Effect Underlines its Nous and Understanding of AR Elements Published May 11, 2022 By
-
8
New Report on Teen Social Media Use Underlines the Rise of TikTok, and the Fall of Facebook Published Aug. 10, 2022 By
-
9
New Report Underlines the Increasing Reliance on Social Platforms for News Content, Including TikTok Published Sept. 20, 2022 By
-
7
New Survey Underlines TikTok’s Popularity with Teen Users Published Nov. 7, 2022 By A...
-
5
Pinterest Underlines the Power of Positivity for Brand Outreach Published June 1, 2023 By
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK