Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Decoration 4: text-decoration-trim</title>
<link rel="author" title="Jonathan Kew" href="mailto:jkew@mozilla.com">
<style>
body {
background: white;
color: black;
}
div {
position: relative;
}
h1 {
position: absolute;
}
u {
text-decoration-color: black;
}
u.green {
text-decoration-color: green;
text-underline-offset: 10px;
}
</style>
<p>The underline for "ultra-quick brown" should be trimmed by .25em at each end;
the additional green underline for "quick" should be extended by .5em at each end:</p>
<div>
<h1>
the ultra<u>-quick</u> brown fox
</h1>
<h1 style="left: .25em; color: transparent">
the <u>ultra</u>-quick brown fox
</h1>
<h1 style="left: -.25em; color: transparent">
the ultra-quick<u> brown</u> fox
</h1>
<h1 style="color: transparent">
the ultra-<u class="green">quick</u> brown fox
</h1>
<h1 style="left: -.5em; color: transparent">
the ultra-<u class="green">quick</u> brown fox
</h1>
<h1 style="left: .5em; color: transparent">
the ultra-<u class="green">quick</u> brown fox
</h1>
</div>