Loading…
Everything will be ready in few seconds
- Theory
- Theory
- Comments
Using margins to format the text
To make the text more readable, we must ensure that there is enough 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. Here is an example of how to use them:
p {
padding: 10px;
margin: 20px 0;
}
In the example above, padding of 10px
is specified for all sides. In addition, external top and bottom margins of 20px
as well as left and right margins of 0px
are specified. These are shorthand properties.
Look at the aside
block on our website. The margins for this block are clearly insufficient. Let’s add them!
- day-2.html
- style.css
Thanks! We’ll fix everything at once!
The code has changed, click “Refresh” or turn autorun on.
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
Comments