What does "a" stand for in font: 0/0 a;
Asked Answered
P

2

28

I was referring a video tutorial where the designer used font: 0/0 a; for image replacement, so I get that 0 is the font-size, another 0 is the line-height but designer skips the a part just by saying that's an hack.

So what does that a exactly do there?

Pallua answered 17/12, 2013 at 17:35 Comment(1)
Relevant: Font Shorthand Syntax. What happens if you run the same code, minus the ` a`?Coleencolella
C
32

http://nicolasgallagher.com/another-css-image-replacement-technique/

font:0/0 a – a shorthand property that zeros out the font size and line-height. The a value acts as a very short font-family (an idea taken from the BEM implementation of this method). The CSS validator complains that using 0/0 in the shorthand font property is not valid, but every browser accepts it and this appears to be an error in the validator. Using font:0px/0 a passes validation but it displayed as font:0/0 a in the code that the validator flags as valid.

Call answered 17/12, 2013 at 17:41 Comment(1)
Setting a only seems necessary in the shorthand notation. Longhand font-size: 0; line-height: 0 works too it seems codepen.io/ryanve/pen/OzOKNdIdealize
C
15

The a is a font name, and of course it's very unlikely that anyone has a font by that name installed.

It's just used to satisfy the CSS syntax, and what font the browser thinks it should use from that is not important, as it won't be used to show any text anyway.


If you use that on an image in order to get rid of spacing around the image, consider using display:block instead.

Churning answered 17/12, 2013 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.