CSS font-weight thicker than 900?
Asked Answered
E

6

34

I have a panel which can be expanded or minimised through a vertically centred link with a < or > symbol as the link text. At font-weight: 900 this does not stand out much, even with a large grey background around it. I do not want to use an image and, at the current font size, both symbols currently take up the maximum width of the panel.

Is there any way to thicken the line on the symbols beyond 900? Or is there another alternative I could use?

Thanks in advance.

Richard

Encaenia answered 16/10, 2010 at 13:39 Comment(0)
R
7

Unfortunately there's no font-weight thicker than 900, and specifying font-weight by number varies across browsers. Your best bet would be to use a thicker font - you haven't specified what you're using, but Impact is relatively thick and tall for its width while being web-safe. Otherwise you could use @font-face to load in a different font.

Rattlebrained answered 16/10, 2010 at 14:11 Comment(1)
I am using font-family: Verdana, Arial, Helvetica, sans-serif. I could just add a class for those links which sets the font to impact... that would work. It shouldnt make it look too much different in style either - only in weight. Thanks for the tip.Encaenia
E
59

In CSS 3 there's another way to make the font size bolder:

color:#888888;    
text-shadow: 2px 0 #888888;
letter-spacing:2px;
font-weight:bold;

EDIT:

For some sort of weird reason this doesn't look as pretty as it did over an year ago. It only works with text-shadow of 1px (on most common fonts, other thicker fonts might still work with 2px). And with text-shadow of only 1px, there's no need for such a large letter-spacing.

color:#888888;    
text-shadow: 1px 0 #888888;
letter-spacing:1px;
font-weight:bold;
Erudite answered 28/1, 2013 at 11:49 Comment(2)
Perfect solution! Thanks!Geordie
That is a neat way to make fonts fatterBioscope
H
21

To add to Gogutz answer, you can go even bolder by stacking up the text-shadows in a grid. Comma separate each on the line:

.extra-bold {
  text-shadow: 0px 1px, 1px 0px, 1px 1px;
}
Hoppe answered 19/11, 2016 at 16:32 Comment(2)
you can also try this: text-shadow: -1px 1px, 1px 1px, 1px 1px;Menticide
This is a great solution, so my thanks to @andy-ballard for the post. 🙌 I made a small variation for high-res phones/displays with text-shadow: 0 0.01em, 0.01em 0, 0.01em 0.01em; and recommend trying the leftmost (without stacking) text-shadow: 0 0.01em; for a subtle bolder effect, then stacking on from left-to-right as needed.Speedometer
R
11

You can use text-shadow instead of font-weight

text-shadow: 0px 1px, 1px 0px, 1px 0px;
Rauwolfia answered 4/12, 2018 at 12:35 Comment(0)
R
7

Unfortunately there's no font-weight thicker than 900, and specifying font-weight by number varies across browsers. Your best bet would be to use a thicker font - you haven't specified what you're using, but Impact is relatively thick and tall for its width while being web-safe. Otherwise you could use @font-face to load in a different font.

Rattlebrained answered 16/10, 2010 at 14:11 Comment(1)
I am using font-family: Verdana, Arial, Helvetica, sans-serif. I could just add a class for those links which sets the font to impact... that would work. It shouldnt make it look too much different in style either - only in weight. Thanks for the tip.Encaenia
A
5

Adding to Gogutz answer. You can use the currentcolor keyword to use the color of the text and avoid hardcoding it.

Like this:

text-shadow: 0.5px 0 currentColor;
letter-spacing: 0.5px;
Affront answered 22/4, 2020 at 19:57 Comment(0)
P
0

This is quite thick. But works only with webkit.

font-size: -webkit-xxx-large;
font-weight: 900; 

enter image description here

Preponderance answered 7/5, 2014 at 14:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.