Home  >  Article  >  Web Front-end  >  How to set css font

How to set css font

coldplay.xixi
coldplay.xixiOriginal
2021-04-15 16:24:2516652browse

How to set css font: 1. Set size em in h2; 2. Font setting needs to use [font-family]; 3. Font thickness setting needs to use attribute [font-weight]; 4 , Font style uses the [font-style] attribute.

How to set css font

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to set css font:

1. Font size setting

Font size setting, there are four common ones Different methods: The size setting in

body{
font-size:14px;
}
h1{
font-size:150%;
}
h2{
font-size:1.2em;
}
h3{
font-size:small;
}

is 14px, which means the height of the font is 14 pixels; the size setting percentage in

h1 is a relative size, which is 150 relative to the body % times; the size setting em in

h2 represents the relative size, which is 1.2 times the size of the body; the size in

h3 is directly the keyword. Commonly used ones are small, medium, large;

2. Font settings

Font settings require font-family settings:

body{
font-family:Verdana,Genva,Arial,sans-serif;
}

3. Font thickness

The font thickness setting requires the attribute font-weight setting:

body{
font-weight:bold;
}

bold means bold, and there are normal, bolder, and lighter. It can also be expressed numerically.

4. Font style

The font style is set with the font-style attribute:

body{
font-style:italic;
}
h1{
font-style:oblique;
}

Related learning recommendations:css tutorial

The above is the detailed content of How to set css font. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn