Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CSS be used for alternate fonts?

Tags:

css

fonts

I know that Alt is used for images in HTML, but is there a way to apply it to text via CSS?

Example:

input { color: #62161e; font-size: 25px; font-family: Lintel; }

So say Lintel does not display properly in some browsers. Is there an alt option to display Helvetica or something?

like image 600
Midtone Avatar asked Nov 18 '11 18:11

Midtone


2 Answers

In CSS, you can specify a list of font families to follow and the browser will use the first one that it supports. So if you want to display Helvetica if Lintel is unavailable, you would simply do this:

font-family: Lintel, Helvetica;

Remember that if the font family has a space in it, you need to surround it in double quotes, like with the line I use for my website:

font-family: "Segoe UI", Arial, Helvetica, sans-serif;
like image 133
animuson Avatar answered Oct 19 '22 23:10

animuson


You can provide multiple fonts and the browser will pick the first available font.

like image 37
SLaks Avatar answered Oct 19 '22 23:10

SLaks