Images can be float
ed to the left
or right
of other elements.
Inline content such as text will flow around the rectangular outline of the image.
Experiment
- Try adding
float: right;
to the teapot class. - Observe that the rest of the article is also reformatted. Add
clear: both
to thearticle
to ensure that doesn't happen - Try adding
padding-left: 4em;
to the teapot class so that the text stays further away. - Notice the image is halfway through the paragraph. What do you think will happen if you move it to the start of the paragraph, after the p tag, but before the text?
It is common to see float
used in older examples of how to layout a page. It is no longer considered best practice because the flex
layout model achieves the same with more predictable and controllable results.