The font-size property
The property value sets the desired height of the font character. The units of measurement can be either absolute or relative.
The most commonly used font size unit is the pixel (px):
p {
font-size: 20px;
}
We also have a special unit of measurement (em) that determines that when the main font size for the parent changes its children elements also proportionally change their font sizes.
The value 1em is the same font size that was assigned to the parent. Accordingly, if we need the font of the child element to always be twice as large as its parent, then we must set the value to 2em:
h1 {
font-size: 2em;
}
The line-height property
The property controls the line height or line spacing.
By default, this property is set to normal. It indicates to the browser that the line spacing must be selected automatically based on the font size. The specification recommends setting it to a value that is 100–120% of the font size. In other words:
p {
font-size: 10px;
line-height: normal; /* The value will be approximately 12px */
}
The normal value allows all texts for which no styles have been applied to be readable. However, if you need to deviate from the default styling, you can assign the line-height a fixed and absolute value that is expressed in px.
p {
font-size: 16px;
line-height: 26px;
}
If you need to set a relative value for the line-height, but you do not want to use a value such as normal, you can specify a percentage or a multiplier as the value. In this case, the browser calculates the value dynamically depending on the font-size:
p {
font-size: 10px;
line-height: 150%; /* Calculated value: 10px * 150% = 15px */
line-height: 2; /* Calculated value: 10px * 2 = 20px */
}
Relative values are more flexible than absolute values. But for simple websites, a fixed font-size and line-height will be adequate.
The font-weight property
This property sets the weight or stroke thickness of the font. The stroke thickness of the font can be thicker or thinner than the normal setting. You can use a keyword or a number as a value. The most commonly used values are:
For example:
h1 {
font-weight: 400; /* The same thing as normal */
}
p {
font-weight: bold; /* The same thing as 700 */
}
The text-align property
It describes how text and other inline elements (images, inline blocks, inline tables, and others) inside the block are justified horizontally.
The property can have the following values:
- left – This aligns the content along the left edge of the block; this is the default value;
- right – This aligns content along the right edge of the block;
- center — This aligns content in the center;
- justify — This fully justifies the content. When this setting is applied, the words in a line are so aligned so as to evenly occupy the entire space of the line (the spaces between words in this case will be uneven, since the browser will “stretch” the words across the line).
It is important to remember that the text-align property is applied in particular to the container block itself within which the text content is located:
HTML:
<p>
I am text inside the paragraph
</p>
CSS:
p {
text-align: center;
}
The vertical-align property
This property can be used to align inline elements for a particular line. The simplest example is to align the <img> image vertically within a text string.
The vertical-align property can be given many values, but the most often used ones are:
- top – It aligns the content along the top edge of the line;
- middle — It aligns the content along the middle of the line;
- bottom — It aligns the content along the bottom edge of the line;
- baseline — It aligns the content along the baseline of the line (default value).
Unlike the text-align property, the vertical-align property is applied to the element itself and not to its container:
HTML:
<p>
<img src="picture.png" alt="I'am a picture">
I am text inside a paragraph
</p>
CSS:
img {
vertical-align: middle;
}
The color property
The color of the text and background can be controlled using the color property.
The color can be specified as a keyword (a full list of keywords is given in the specification). For example:
color: black; /* Black */
color: red; /* Red */
color: white; /* White */
Another way to specify color is to indicate a hexadecimal value. In this case, the color is formed from the red, green and blue components that are specified as a hexadecimal number that ranges from 00 to ff. In addition to the six-character hexadecimal format, the color code may also consist of a three-character triplet. In this case, the second character in the color components is duplicated first:
color: #000000; /* Black */
color: #f00; /* Red, which is the same as #ff0000 */
color: #fff; /* White, which is the same as #ffffff */
If you do not want to deal with hexadecimal values, you can use the special rgb function, which specifies the color in a more familiar decimal format within the range of 0 to 255. This code also consists of three color components that are separated by commas:
color: rgb(0, 0, 0) /* Black, which is the same as #000000 */
color: rgb(255, 0, 0) /* Red, which is the same as #ff0000 */
color: rgb(255, 255, 255) /* White, which is the same as #ffffff */
The rgb function has an extended version: rgba. In this case, the code not only specifies the color: the last value in the code indicates the degree of opacity of the color, which is also known as its alpha. The value may vary from 0 (fully transparent) to 1 (fully opaque):
color: rgba(0, 0, 0, 0.5) /* Black, 50% opaque */
color: rgb(255, 0, 0, 0.3) /* Red, 30% opaque */
color: rgb(255, 255, 255, 0.9) /* White, 90% opaque */
Color contrast between the text and background
The background image and the background color of the block should always strongly contrast with the text color in this block. The greater the contrast, the easier it will be to read the text under different lighting conditions and on different devices. Therefore, if you set a background image for a block, you must additionally set a suitable background color. In this case, the text can still be read while the image is still loading or if it fails to load at all:
p {
/* An ideal level of contrast: the text color is white, the background color is black */
background-color: #000000;
color: #ffffff;
}
span {
/* A bad level of contrast: the text and background colors are both gray */
background-color: #cccccc;
color: #ddddddd;
}
The white-space property, space management
The browser ignores multiple spaces and line breaks in the HTML code. However, you can use the white-space property to control extra spaces and line breaks. The property takes the following values:
- nowrap – It collapses extra spaces and displays all of the text in one line without any line breaks.
- pre – It preserves all spaces and line breaks that are included in the source code in a way that is similar to the <pre> tag.
- pre-wrap — It functions similarly to the pre tag. However, it automatically adds line breaks if the text does not fit inside the container.
- normal – This is the default mode: extra spaces and line breaks are collapsed. The text is transferred while the spaces at the end of lines are removed.
The text-decoration property
It assigns additional formatting to the text. The property values are:
- underline — It underlines text;
- line-through — It crosses out text;
- overline — It overlines text;
- none — It removes the above formatting.
You can apply several effects to the text at the same time by listing the values separated by a space:
p {
text-decoration: underline; /* It underlines the text. */
}
span {
/* The text is both underlined and crossed out. */
text-decoration: underline line-through;
}
The text-decoration property is shorthand. It is broken down into separate properties:
- text-decoration-line — This defines the line formatting: crossed-out, underlined or overlined;
- text-decoration-style — This defines the line style. It can take the following properties:
- solid — Solid line;
- double — Double line;
- dotted — Dotted line;
- dashed — Dashed line;
- wavy — Wavy line.
- text-decoration-color — Line color.
The font-style property
This property can be used to set the font face. Its basic properties are as follows:
- normal — Normal font face;
- italic — Italics font face.
- oblique — Slanted font face.
If you set the value to italic, the browser will try to find a separate italics font face for the characters for the given font. Some fonts specify a separate set of italics characters.
If there are no separate italics characters in the font, then the browser will make the text slanted, which is a way of simulating italics. This is the equivalent to specifying the value font-style: oblique for the text.
The text-transform property
You can also use it to control the case of characters: you can make letters lowercase (small) or uppercase (large). The property values are:
- lowercase — It formats everything as lowercase;
- uppercase — It formats everything as uppercase;
- capitalize — Every word starts with a capital letter;
- none — It cancels any change to the case.
Margins
An important factor that determines the readability of the text in the block is ensuring sufficient free space in the block for this text. There must be enough space around the text. It should not touch the edges, and it should not be crowded.
Two properties are responsible for margins in CSS: padding sets the padding in the block, and margin sets the external margins.
Continue
<!DOCTYPE html><html lang="en" class="no-js"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><script>var b=document.documentElement.classList;b.remove('no-js');if(!window.Promise||!window.sessionStorage||!!sessionStorage.getItem('muller.v2')){b.add('muller')}</script><link rel="dns-prefetch" href="https://assets.htmlacademy.org"><script async src="https://www.googletagmanager.com/gtag/js?id=G-MXPCRXM48C"></script><script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MXPCRXM48C');
</script><script type="text/javascript">
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
;r.type="text/javascript"
;r.integrity="sha384-d/yhnowERvm+7eCU79T/bYjOiMmq4F11ElWYLmt0ktvYEVgqLDazh4+gW9CKMpYW"
;r.crossOrigin="anonymous";r.async=true
;r.src="https://cdn.amplitude.com/libs/amplitude-5.2.2-min.gz.js"
;r.onload=function(){if(!e.amplitude.runQueuedFunctions){
console.log("[Amplitude] Error: could not load SDK")}}
;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)
;function s(e,t){e.prototype[t]=function(){
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
var o=function(){this._q=[];return this}
;var a=["add","append","clearAll","prepend","set","setOnce","unset"]
;for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[]
;return this}
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
;for(var p=0;p<l.length;p++){s(c,l[p])}n.Revenue=c
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","groupIdentify","onInit","logEventWithTimestamp","logEventWithGroups","setSessionId","resetSessionId"]
;function v(e){function t(t){e[t]=function(){
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){
e=(!e||e.length===0?"$default_instance":e).toLowerCase()
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]}
;e.amplitude=n})(window,document);
amplitude.getInstance().init("df11525b6880a3c5e2af14f9b6238408", null,{
includeUtm: true,
includeGclid: true,
includeReferrer: true,
deviceIdFromUrlParam: true
}, function (instance) {
window.amplitudeLoaded = true;
});
</script><link rel="stylesheet" href="https://assets.htmlacademy.org/css/core.v284.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/profile.v236.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course.v246.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course-interface-light.v20.css"><link rel="stylesheet" href="https://assets.htmlacademy.org/css/course-interface-en.v2.css"><script src="https://assets.htmlacademy.org/js/sentry.js" data-sentry="3774884cc81746ed84c0ba7c5cd4ac7b" data-project="26" data-version="2"></script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/cookies.css"><link rel="preload" as="script" href="https://assets.htmlacademy.org/js/general.v274.js"><title>Summary of “Typography” — Typography — HTML Academy</title><meta name="csrf-token" content="30464caf322823086fca37a7326b9bd2a54"><meta property="og:type" content="website"><meta property="og:site_name" content="HTML Academy"><meta name="twitter:url" property="og:url" content="https://htmlacademy.org"><meta name="twitter:title" property="og:title" content="Interactive online courses HTML Academy"><meta name="twitter:description" property="og:description" content="Together we’ll learn how to work with real code, solve true-to-life problems, use cutting edge technologies. Minimum of boring theory and lots of practical tasks."><meta name="twitter:image" property="og:image" content="https://htmlacademy.org/og/htmlacademy.png"><meta name="twitter:card" content="summary_large_image"><link rel="canonical" href="https://htmlacademy.org/courses/html-css-basics/typography/summary"><meta name="theme-color" content="#2f358f"></head><body class="course-interface course-interface--light course-interface--full" data-base="/assets/courses/17/"><header class="page-header page-header--course"><div class="page-header__inner"><div class="page-header__top"><a class="page-header__logo" href="/" aria-label="HTML Academy Home"><img src="https://assets.htmlacademy.org/img/logo--small.svg?cs=1218aec0be4a5f23db79ad29a14e30f7f9fb9a25" width="24" height="36" alt="HTML Academy"></a><nav class="main-nav main-nav--mini" role="navigation"><div class="main-nav__course-nav"><a class="main-nav__course-item main-nav__course-button main-nav__course-button--prev" href="/courses/html-css-basics/typography/styling-footer">Shave space off the footer</a><div class="main-nav__course-item main-nav__course-list main-nav__course-list--collapsed"><b class="main-nav__course-title">Typography</b><span class="main-nav__course-stat">19/20</span><div class="main-nav__course-contents"><a class="main-nav__course-contents-link" href="/courses/html-css-basics/typography">Back to the list of tasks</a><ul class="main-nav__course-contents-list"><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/font-size">1. The font-size property</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/relative-font-size">2. Relative font size</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/line-height">3. The line-height property</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/relative-line-height">4. Relative line height</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/font-family">5. The font-family property</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/font-weight">6. The font-weight property</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-align">7. The text-align property, horizontal text alignment</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/more-text-align">8. The text-align property does more than just align text</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/vertical-align">9. The vertical-align property, vertical text alignment</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-background">10. Use of the background in typography</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-color">11. The color property, text color</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-margins">12. Using margins to format the text</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/white-space">13. The white-space property, space management</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/preformatted-text">14. Assignment of styles to preformatted text</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-decoration">15. The text-decoration property, underlining as well as other effects</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/font-style">16. The font-style property, italics</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/text-transform">17. The text-transform property, character case</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/styling-footer">18. Shave space off the footer</a></li><li class="main-nav__course-contents-item main-nav__course-contents-item--current"><a href="/courses/html-css-basics/typography/summary">19. Summary of “Typography”</a></li><li class="main-nav__course-contents-item"><a href="/courses/html-css-basics/typography/designing-article">20. Test: Designing an article</a></li></ul></div></div><a class="main-nav__course-item main-nav__course-button main-nav__course-button--next" href="/courses/html-css-basics/typography/designing-article">Test: Designing an article</a></div><ul class="main-nav__list main-nav__list--user main-nav__list--user-guest"><li class="main-nav__item" itemprop="name"><a class="main-nav__link" href="/signup?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" title="Sign up" data-modal="open" data-value="register" itemprop="url"><span class="main-nav__icon" aria-hidden="true"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#user"></use></svg></span>Sign up</a></li><li class="main-nav__item main-nav__item--login" itemprop="name"><a class="main-nav__link" href="/login?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" title="Log in" data-modal="open" data-value="login" itemprop="url"><span class="main-nav__icon" aria-hidden="true"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#login"></use></svg></span>Log in</a></li></ul></nav></div></div></header><main class="course-container"><div class="course-theory"><div class="course-theory__inner"><section class="course-theory__content"><h1 class="course-theory__content-heading course-theory__content-heading--synopsis">Summary of “Typography”</h1><div class="course-theory__content-text"><h2>The font-size property</h2><p>The property value sets the desired height of the font character. The units of measurement can be either <a href="/courses/html-css-basics/css-essentials/absolute-relative-values">absolute or relative</a>.</p><p>The most commonly used font size unit is the pixel (<code>px</code>):</p><pre><code>p {
font-size: 20px;
}</code></pre><p>We also have a special unit of measurement (<code>em</code>) that determines that when the main font size for the parent changes its children elements also proportionally change their font sizes.</p><p>The value <code>1em</code> is <i>the same</i> font size that was assigned to the parent. Accordingly, if we need the font of the child element to always be twice as large as its parent, then we must set the value to <code>2em</code>:</p><pre><code>h1 {
font-size: 2em;
}</code></pre><h2>The line-height property</h2><p>The property controls the line height or line spacing.</p><p>By default, this property is set to <code>normal</code>. It indicates to the browser that the line spacing must be selected automatically based on the font size. The <a href="https://www.w3.org/TR/CSS2/visudet.html#propdef-line-height" target="_blank" rel="noopener nofollow">specification</a> recommends setting it to a value that is <code>100–120%</code> of the font size. In other words:</p><pre><code>p {
font-size: 10px;
line-height: normal; /* The value will be approximately 12px */
}</code></pre><p>The <code>normal</code> value allows all texts for which no styles have been applied to be readable. However, if you need to deviate from the default styling, you can assign the <code>line-height</code> a fixed and absolute value that is expressed in <code>px</code>.</p><pre><code>p {
font-size: 16px;
line-height: 26px;
}</code></pre><p>If you need to set a relative value for the <code>line-height</code>, but you do not want to use a value such as <code>normal</code>, you can specify a percentage or a multiplier as the value. In this case, the browser calculates the value dynamically depending on the <code>font-size</code>:</p><pre><code>p {
font-size: 10px;
line-height: 150%; /* Calculated value: 10px * 150% = 15px */
line-height: 2; /* Calculated value: 10px * 2 = 20px */
}</code></pre><p>Relative values are more flexible than absolute values. But for simple websites, a fixed <code>font-size</code> and <code>line-height</code> will be adequate.</p><h2>The font-weight property</h2><p>This property sets the weight or stroke thickness of the font. The stroke thickness of the font can be thicker or thinner than the normal setting. You can use a keyword or a number as a value. The most commonly used values are:</p><ul><li><p><code>400</code> or <code>normal</code> — Regular font with the default value;</p></li><li><p><code>700</code> or <code>bold</code> — Bold font.</p></li></ul><p>For example:</p><pre><code>h1 {
font-weight: 400; /* The same thing as normal */
}
p {
font-weight: bold; /* The same thing as 700 */
}</code></pre><h2>The text-align property</h2><p>It describes how text and other <code>inline</code> elements (images, inline blocks, inline tables, and others) inside the block are justified horizontally.</p><p>The property can have the following values:</p><ol><li><code>left</code> – This aligns the content along the left edge of the block; this is the default value;</li><li><code>right</code> – This aligns content along the right edge of the block;</li><li><code>center</code> — This aligns content in the center;</li><li><code>justify</code> — This fully justifies the content. When this setting is applied, the words in a line are so aligned so as to evenly occupy the entire space of the line (the spaces between words in this case will be uneven, since the browser will “stretch” the words across the line).</li></ol><p>It is important to remember that the <code>text-align</code> property is applied in particular to the container block itself within which the text content is located:</p><pre><code>HTML:
<p>
I am text inside the paragraph
</p>
CSS:
p {
text-align: center;
}</code></pre><h2>The vertical-align property</h2><p>This property can be used to align <i>inline</i> elements for a particular line. The simplest example is to align the <code><img></code> image vertically within a text string.</p><p>The <code>vertical-align</code> property can be given many values, but the most often used ones are:</p><ol><li><code>top</code> – It aligns the content along the top edge of the line;</li><li><code>middle</code> — It aligns the content along the middle of the line;</li><li><code>bottom</code> — It aligns the content along the bottom edge of the line;</li><li><code>baseline</code> — It aligns the content along the baseline of the line (default value).</li></ol><p>Unlike the <code>text-align</code> property, the <code>vertical-align</code> property is applied to the element itself and not to its container:</p><pre><code>HTML:
<p>
<img src="picture.png" alt="I'am a picture">
I am text inside a paragraph
</p>
CSS:
img {
vertical-align: middle;
}</code></pre><h2>The color property</h2><p>The color of the text and background can be controlled using the <code>color</code> property.</p><p>The color can be specified as a keyword (a full list of keywords is given in the <a href="https://www.w3.org/TR/css-color-3/#svg-color" target="_blank" rel="nofollow noopener">specification</a>). For example:</p><pre><code>color: black; /* Black */
color: red; /* Red */
color: white; /* White */</code></pre><p>Another way to specify color is to indicate a <a href="https://en.wikipedia.org/wiki/Hexadecimal" target="_blank" rel="nofollow noopener">hexadecimal value</a>. In this case, the color is formed from the <i>red</i>, <i>green</i> and <i>blue</i> components that are specified as a hexadecimal number that ranges from <code>00</code> to <code>ff</code>. In addition to the six-character hexadecimal format, the color code may also consist of a three-character triplet. In this case, the second character in the color components is duplicated first:</p><pre><code>color: #000000; /* Black */
color: #f00; /* Red, which is the same as #ff0000 */
color: #fff; /* White, which is the same as #ffffff */
</code></pre><p>If you do not want to deal with hexadecimal values, you can use the special <code>rgb</code> function, which specifies the color in a more familiar decimal format within the range of <code>0</code> to <code>255</code>. This code also consists of three color components that are separated by commas:</p><pre><code>color: rgb(0, 0, 0) /* Black, which is the same as #000000 */
color: rgb(255, 0, 0) /* Red, which is the same as #ff0000 */
color: rgb(255, 255, 255) /* White, which is the same as #ffffff */</code></pre><p>The <code>rgb</code> function has an extended version: <code>rgba</code>. In this case, the code not only specifies the color: the last value in the code indicates the degree of opacity of the color, which is also known as its alpha. The value may vary from <code>0</code> (fully transparent) to <code>1</code> (fully opaque):</p><pre><code>color: rgba(0, 0, 0, 0.5) /* Black, 50% opaque */
color: rgb(255, 0, 0, 0.3) /* Red, 30% opaque */
color: rgb(255, 255, 255, 0.9) /* White, 90% opaque */</code></pre><h2>Color contrast between the text and background</h2><p>The background image and the background color of the block should always strongly contrast with the text color in this block. The greater the contrast, the easier it will be to read the text under different lighting conditions and on different devices. Therefore, if you set a background image for a block, you must additionally set a suitable background color. In this case, the text can still be read while the image is still loading or if it fails to load at all:</p><pre><code>p {
/* An ideal level of contrast: the text color is white, the background color is black */
background-color: #000000;
color: #ffffff;
}
span {
/* A bad level of contrast: the text and background colors are both gray */
background-color: #cccccc;
color: #ddddddd;
}
</code></pre><h2>The white-space property, space management</h2><p>The browser ignores multiple spaces and line breaks in the HTML code. However, you can use the <code>white-space</code> property to control extra spaces and line breaks. The property takes the following values:</p><ul><li><code>nowrap</code> – It collapses extra spaces and displays all of the text in one line without any line breaks.</li><li><code>pre</code> – It preserves all spaces and line breaks that are included in the source code in a way that is similar to the <code><pre></code> tag.</li><li><code>pre-wrap</code> — It functions similarly to the <code>pre</code> tag. However, it automatically adds line breaks if the text does not fit inside the container.</li><li><code>normal</code> – This is the default mode: extra spaces and line breaks are collapsed. The text is transferred while the spaces at the end of lines are removed.</li></ul><h2>The text-decoration property</h2><p>It assigns additional formatting to the text. The property values are:</p><ol><li><code>underline</code> — It underlines text;</li><li><code>line-through</code> — It crosses out text;</li><li><code>overline</code> — It overlines text;</li><li><code>none</code> — It removes the above formatting.</li></ol><p>You can apply several effects to the text at the same time by listing the values separated by a space:</p><pre><code>p {
text-decoration: underline; /* It underlines the text. */
}
span {
/* The text is both underlined and crossed out. */
text-decoration: underline line-through;
}</code></pre><p>The <code>text-decoration</code> property is <a href="/courses/html-css-basics/css-essentials/css-shorthand-properties">shorthand</a>. It is broken down into separate properties:</p><ul><li><code>text-decoration-line</code> — This defines the line formatting: crossed-out, underlined or overlined;</li><li><code>text-decoration-style</code> — This defines the line style. It can take the following properties:
<ul><li><code>solid</code> — Solid line;</li><li><code>double</code> — Double line;</li><li><code>dotted</code> — Dotted line;</li><li><code>dashed</code> — Dashed line;</li><li><code>wavy</code> — Wavy line.</li></ul></li><li><code>text-decoration-color</code> — Line color.</li></ul><h2>The font-style property</h2><p>This property can be used to set the font face. Its basic properties are as follows:</p><ol><li><code>normal</code> — Normal font face;</li><li><code>italic</code> — Italics font face.</li><li><code>oblique</code> — Slanted font face.</li></ol><p>If you set the value to <code>italic</code>, the browser will try to find a separate italics font face for the characters for the given font. Some fonts specify a separate set of italics characters.</p><p>If there are no separate italics characters in the font, then the browser will make the text slanted, which is a way of simulating italics. This is the equivalent to specifying the value <code>font-style: oblique</code> for the text.</p><h2>The text-transform property</h2><p>You can also use it to control the case of characters: you can make letters lowercase (small) or uppercase (large). The property values are:</p><ol><li><code>lowercase</code> — It formats everything as lowercase;</li><li><code>uppercase</code> — It formats everything as uppercase;</li><li><code>capitalize</code> — Every word starts with a capital letter;</li><li><code>none</code> — It cancels any change to the case.</li></ol><h2>Margins</h2><p>An important factor that determines the readability of the text in the block is ensuring sufficient free space in the block for this text. There must be enough space around the text. It should not touch the edges, and it should not be crowded.</p><p>Two properties are responsible for margins in CSS: <code>padding</code> sets the padding in the block, and <code>margin</code> sets the external margins.</p><br><a class="button button--green button--large button--wide button--icon" href="/courses/html-css-basics/typography/designing-article"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#icon-check-bold"></use></svg>
Continue
</a></div></section></div></div><script
src="https://assets.htmlacademy.org/scripts/courses-spa/htmlacademy-task.v43.js"
data-assets-path="https://assets.htmlacademy.org/scripts/courses-spa/"
data-task-type="theory"
data-lang="en"
></script><script>HtmlacademyTask.setup(function(){});</script></main><footer class="page-footer page-footer--tiny"><div class="page-footer__inner"><p><a href="/docs/cookies">Cookies</a> ∙
<a href="/docs/privacy">Privacy</a> ∙
<a href="/docs/agreement">License Agreement</a> ∙
<a href="/docs/about">About</a> ∙
<a href="/contacts">Contacts</a> ∙
© HTML Academy OÜ, 2019−2026
</p><div class="page-footer__financial"><img src="https://assets.htmlacademy.org/img/visa-white.svg?cs=96e54ec8c587db9d4b1d8d328ffd87c2ebfd9555" alt="VISA" title="VISA" width="35" height="35"><img src="https://assets.htmlacademy.org/img/mastercard-horizontal.v2.svg" alt="Mastercard" title="Mastercard" width="35" height="35"></div></div></footer><div class="modal"><div class="modal__inner"><div class="modal__wrapper js-login hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Log in</h4><ul class="modal__social"><li class="modal__social-link modal__social-link--fb"><a href="/login/fb?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" rel="nofollow" title="Log in via Facebook"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#facebook"></use></svg></a></li><li class="modal__social-link modal__social-link--google"><a href="/login/google?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" rel="nofollow" title="Log in via Google"><svg height="30" width="30" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M457.732 216.625c2.628 14.041 4.063 28.743 4.063 44.098C461.796 380.688 381.481 466 260.204 466c-116.023 0-210-93.977-210-210s93.977-210 210-210c56.704 0 104.077 20.867 140.44 54.73l-59.204 59.197v-.135c-22.046-21.002-50-31.762-81.236-31.762-69.297 0-125.604 58.537-125.604 127.841 0 69.29 56.306 127.968 125.604 127.968 62.87 0 105.653-35.965 114.46-85.312h-114.46v-81.902h197.528z"/></svg></a></li></ul><div class="modal__or"><span>or</span></div><form class="modal__form form" action="/login?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" autocomplete="off" method="post" data-submit="o"><input type="hidden" name="csrf_name" value="csrf69aea7bb8f15c"><input type="hidden" name="csrf_value" value="21224740a657b150712965b90ef5f824"><div class="form__group"><label class="sr-only" for="login-email">Email</label><input class="field field--text field--full-width" type="email" name="email" placeholder="Email" value="" id="login-email"></div><div class="form__group"><label class="sr-only" for="login-password">Password</label><input class="field field--text field--full-width ym-disable-keys" type="password" name="password" placeholder="Password" id="login-password"></div><input class="button button--full-width" type="submit" data-submit-text="Logging in…" value="Log in"></form><p class="modal__forgot-password"><a href="/recover" data-modal="open" data-value="recover">Forgot your password?</a></p><a class="modal__bottom-link" href="/signup" data-modal="open" data-value="register">Sign up</a></div><div class="modal__wrapper js-register hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Sign up</h4><ul class="modal__social"><li class="modal__social-link modal__social-link--fb"><a href="/login/fb?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" rel="nofollow" title="Log in via Facebook"><svg aria-hidden="true"><use xlink:href="/img/sprites/general.svg#facebook"></use></svg></a></li><li class="modal__social-link modal__social-link--google"><a href="/login/google?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" rel="nofollow" title="Log in via Google"><svg height="30" width="30" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M457.732 216.625c2.628 14.041 4.063 28.743 4.063 44.098C461.796 380.688 381.481 466 260.204 466c-116.023 0-210-93.977-210-210s93.977-210 210-210c56.704 0 104.077 20.867 140.44 54.73l-59.204 59.197v-.135c-22.046-21.002-50-31.762-81.236-31.762-69.297 0-125.604 58.537-125.604 127.841 0 69.29 56.306 127.968 125.604 127.968 62.87 0 105.653-35.965 114.46-85.312h-114.46v-81.902h197.528z"/></svg></a></li></ul><div class="modal__or"><span>or</span></div><form class="modal__form form" action="/signup?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" autocomplete="off" method="post"><input type="hidden" name="csrf_name" value="csrf69aea7bb8f15c"><input type="hidden" name="csrf_value" value="21224740a657b150712965b90ef5f824"><div class="form__group"><label class="sr-only" for="email">
Email
<span class="required"><span class="sr-only">Required field</span><span class="required__star">*</span></span></label><div class="form__group-fields"><input class="field field--text field--full-width" type="email" name="email" value="" id="email" required placeholder="Email"></div></div><div class="form__group"><label class="sr-only" for="password">
Password
<span class="required"><span class="sr-only">Required field</span><span class="required__star">*</span></span></label><div class="form__group-fields"><input class="field field--text field--full-width" type="password" name="password" value="" id="password" required placeholder="Password"></div></div><div class="form__group"><label class="checkbox"><input class="checkbox__input" type="checkbox" name="agreement" value="1" required><span class="checkbox__text"><span>By signing up, you agree to our <a href="/docs/agreement" target="_blank">License Agreement</a> and <a href="/docs/privacy" target="_blank">Privacy Policy</a>.</span></span></label></div><input class="button button--full-width" type="submit" data-submit-text="Signing up…" value="Sign up"></form><a class="modal__bottom-link" href="/login?redirect_url=%2Fcourses%2Fhtml-css-basics%2Ftypography%2Fsummary" data-modal="open" data-value="login">Log in</a></div><div class="modal__wrapper modal__wrapper--no-btn-bottom js-recover hidden"><button class="modal__close icon-close" type="button" title="Close" data-modal="close"></button><h4 class="modal__header">Restore access</h4><p class="modal__text-accent">Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.</p><form class="modal__form form" action="/recover" autocomplete="off" method="post" data-submit="o"><input type="hidden" name="csrf_name" value="csrf69aea7bb8f15c"><input type="hidden" name="csrf_value" value="21224740a657b150712965b90ef5f824"><div class="form__group"><label class="sr-only" for="recovery-email">Email</label><input class="field field--text field--full-width" type="email" name="email" placeholder="Email" value="" id="recovery-email"></div><script src='https://www.google.com/recaptcha/api.js'></script><div class="form__group"><div class="g-recaptcha" data-sitekey="6LetCTEqAAAAANROWtPzfC7Rfg9iIRiRt2k2FPn7"></div></div><input class="button button--full-width" type="submit" data-submit-text="Sending…" value="Send"></form><p class="modal__text">Forgot to connect your email to the profile? Email us and we’ll help.</p></div></div></div><script async src="https://assets.htmlacademy.org/js/general.v274.js" data-assets="https://assets.htmlacademy.org" data-require="toggle,navigation-courses,modal,form,nav"></script></body></html>