This weird trick to hide your site name
I took a look at Google’s parent company Alphabet’s website today. It a clean little one-pager. The thing I noticed was their handling of the logo.
At first it looks like a simple logo font. Turns out their doing some old-school web shenanigans.
- background-repeat: no-repeat;
- background-position: 0 0;
- color: transparent;
- font: 0 / 0 a;
- text-shadow: none;
- background: url(../img/logo_2x.png) 0 0 no-repeat;
- background-size: 100px 24px;
- height: 24px;
- left: 24px;
- position: absolute;
- top: 18px;
- width: 100px;
- z-index: 999;
Notice the `color: transparent;` and `font: 0 / 0 a;`? In the past we usually saw `position: absolute; left: 9999px;` or something to through it off the page. This is basically the same thing, they’re just shrinking the font to nothing, and making it transparent. Actually, the font declaration caught my eye. Turns out it’s short-hand for `
- font-size: 0px;
- line-height: ;
- font-family: a;`
For the most part it’s very neat, simple and clean. Even this feels like a neater version of that old hack. However, it’s standard now to not hide text in anyway, but instead to render a picture element with a title and alt tag.