New May 2, 2026

A CSS Challenge

More Front-end Bloggers All from Kitty Giraudel View A CSS Challenge on kittygiraudel.com

Yesterday night, I’ve seen something in my Twitter timeline which excited my curiosity: a CSS challenge. It was proposed by Raphaël Goetter, a famous French frontend developer on his blog.

Since I’m sure you’ll be interested in a little CSS riddle (you will, will you?), let me tell you what this is about.

Some text content sitting on top of a horizontal line, and masking said line behind the letters

Will you be able to do this (I’m talking about the small line behind the text) following the restrictions below?

I can’t wait to see the way you’ll figure this out people. I personally found something with a few downsides sadly. I’m sure some of you will be able to find a kick-ass solution. ;)

Good luck!

[Edit] Solutions (November 24th, 2012)

Thanks for participating! There have been a couple of answers for this trick. Druid of Lûhn proposed something which works but sadly it’s pretty awful for SEO since it involves an empty h1 tag.

Joshua Hibbert used linear gradients to do it (so did Raphael Goetter). This is a clever technique I thought about but didn’t give a try. My experience with gradients is not that good.

Here is the way I did it:

body {
	text-align: center;
	overflow: hidden;
	background: #ffa;
}

h1 { display: -moz-inline-box; display: inline-block; *display: inline; *zoom: 1; position: relative; font-size: 30px; margin-top: 20px; }

h1:after, h1:before { content: ''; position: absolute; height: 1px; width: 1000px; top: 50%; inset-inline-end: 100%; background: black; }

h1:after { left: 100%; }

So basically, I used both pseudo-elements to create the line. To place them, I set the title to inline-block, and the parent (body) text-align to center.

Sadly, a few things suck with this technique, even if it works pretty well:

Hopefully the browser support is pretty good, at least way better than the gradient version:

But since it’s only a tiny design improvement, I’ll definitely go with the gradient version on a live project. Thanks for participating. I’ll try to drop another challenge soon. :)

Scroll to top