Tagged “underline”
New CSS for Styling Underlines on the Web - YouTube
We have new properties in CSS for styling underlines, as explained here by Jen Simmons.
The relevant properties are:
text-decoration-thickness
text-decoration-color
text-underline-offset
text-decoration-skip-ink
The skip-ink concept becomes more interesting (to me at least) when you're also using the other properties (especially offset) in order to start the underline higher up the word causing it to appear behind it.
Update 25th November 2022
The Contrast Triangle
Removing underlines from links in HTML text presents an accessibility challenge. In order for a design to be considered accessible, there is now a three-sided design contraint - or what I call "The Contrast Triangle". Your text, links and background colors must now all have sufficient contrast from each other. Links must have a contrast ratio of 3:1 from their surrounding text. By not using underlines, a design has to rely on contrast alone to achieve this.
It’s interesting that Chip says that this level of contrast is needed “when we don’t use underlines on links”.
By not using underlines, a design has to rely on contrast alone to achieve this.
So this seems to be yet another good reason to include underlines in links, i.e. if you underline your links then you don’t need to worry quite as much about a third level of contrast.
Indeed, when you toggle on the “Show underlines” option on this tool, it then removes the requirement to ensure additional contrast between hyperlinks and standard body text.
However, even if your links in flowing prose are underlined, there’s always likely to be places (Navigation, Footer, CTAs etc) where you’ve probably disabled underlines on links for design effect, so I reckon this is useful for most websites.
(via https://twitter.com/jamesmockett)
Animating the underlining of multi-line text
Cassie Evans shows us how to combine background–size
, a linear-gradient
based background-image
and a keyframe animation (all in HTML and CSS) for a lovely progressive underline effect on multi-line text.
Here’s the gist of it:
<h2>This is a multi-line spanning animated underline. This took an annoyingly long time to figure out.</h2>
body {
padding: 40vh 30vw;
font-family: cursive;
text-align: left;
font-size: 130%;
}
h2 {
line-height: 1.5;
display: inline;
background-image: linear-gradient(
transparent 50%,
#e1fffe 50%,
#b0f8ff 85%,
transparent 85%,
transparent 100%
);
background-repeat: no-repeat;
background-size: 0% 100%;
animation: animatedBackground 2s cubic-bezier(0.645, 0.045, 0.355, 1) 0.5s forwards;
}
@keyframes animatedBackground {
to {
background-size: 100% 100%;
}
}
Thanks, Cassie!
See all tags.