Font properties Introduction
CSS
The font attribute is doing it? Fonts and font sure about the strategy, is to set theHTML
page Chinese version of the font,
CSS
the font attributes There are several commonly used it, I give you the next comb, a total of more common5
species, today we look at this5
kind of text to give font bring any results so far.CSS
Font attribute defines the text font family, size, bold, style (such as italics).- In
CSS
five species commonly used font attributes, suchfont-style
as:font-weight
,font-size
,font-family
,font
, .
provided italic font-style
font-style
The main attribute is used to set the text in italics.
font-style attribute Table
value | description |
---|---|
normal | The italic font back to normal. |
italic | Set the font to italic. |
- Let us enter
font-style
the property practice, practice content such as: theHTML
pagep
text font tag set in italics. If we do not use the
font-style
property, can not be p tag text font to italic it? If we learnHTML
also, should know that there is one among HTMLi
tagsi
The tag is the text's font to italic, built-in functions.
A little long-winded, huh, oh beginners popularity at the details.-
Block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>设置字体为斜体</title>
</head>
<body>
<p>成功不是打败别人,而是改变自己。</p>
<p><i>成功不是打败别人,而是改变自己。</i></p>
</body>
</html>
-
Results Figure
-
Note: Use
font-style
property can bei
the label comes to function italics removed, such as: Oh below critical code.
<style>
i{
font-style: normal;
}
</style>
- Use
font-style
property of the text is italic font. -
Block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>设置字体为斜体</title>
</head>
<style>
p{
font-style: italic;
}
</style>
<body>
<p>成功不是打败别人,而是改变自己。</p>
</body>
</html>
-
Results Figure
font-weight font weight set
font-weight
Property is used to set the text font weight.
font-weight property description table
Property Value | description |
---|---|
normal | The thickness of the restoration of normal text. |
bold | Bold font. |
100-900 | Bold font |
- Let us enter the
font-weight
property practice, the contents of the HTML pagep
label text font bold, I use theclass
attribute value.box
to the firstp
label text font is bold900
, why does theclass
property value.box
it, easy for beginners to understand, the rest are Like, it does not show too much. -
Block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>设置字体粗细</title>
</head>
<style>
.box{
font-weight:900;
}
</style>
<body>
<p class="box">成功不是打败别人,而是改变自己。</p>
<p>成功不是打败别人,而是改变自己。</p>
</body>
</html>
-
Results Figure
font-size to set the font size
font-size
Property is to set the font size of text, because thefont-size
property value is relatively simple, do notfont-size
attribute table explains the description,font-size
property valuepx
for the units.- Let us enter
font-size
the property practice, practice content such as: theHTML
pagep
label text font size is set to14
pixels. -
Block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>设置字体大小</title>
</head>
<style>
p{
font-size: 14px;
}
</style>
<body>
<p>成功不是打败别人,而是改变自己。</p>
</body>
</html>
-
Results Figure
font-family font settings
font-family
Set the font style attributes to text, such as: Microsoft elegant black, italics, Times New Roman ....- Friends of the Park have seen here, I believe we have a certain amount of self-learning ability, and will not introduce, directly on the key code, you can try to own a variety of fonts and Kazakhstan.
-
Block
font-family: "微软雅黑";
-
Note:
font-family
attribute may be used such as a plurality of:font-family: "微软雅黑","宋体",....;
-
Details: General very special font, the site above are using images to represent. Whether this font is displayed according to the user's computer which corresponds font file, if the file will not be displayed as Times New Roman.
Abbreviations font font settings
- Acronym property can be simultaneously set in italics, bold, size, font to the text, to use a comma between each value and must be sequentially.
- Let us enter the
font
font settings abbreviation practice, practice content such as: thep
label Chinese text to italic, bold, size, font. -
Block
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>字体设置的缩写</title>
</head>
<style>
p{
font: italic 900 14px "微软雅黑";
}
</style>
<body>
<p>成功不是打败别人,而是改变自己。</p>
</body>
</html>
-
Results Figure