You will also notice that vertical paddings, bor ders, and ma rgins of the <div> element,
which now has inline display, are totally disregarded by the surrounding elements. The
content box of the body is ju st high enough to contain the content box of the <div>
element, which is placed tightly around the text “I am a box.” If we removed the body’s
padding, then the top border of the <div> element might even move off the document
window. However, h orizontal paddings, borders, and margins of an inline element are
still respected by neighbor ing elements. It is important that you understand this, as it
influences the position ing of the elements.
5.4 Positioning and Element Flow
Professor: The next important concept connected with the placin g of elements on a
page is the element flow. Normally, elements appear on a page in the same order as
they do in the HTML file, which means that they are in the document flow or just in
the flow. If an element is in the flow, then other elements respect its presen ce and
place themselves accordingly. For example, if there’s a para graph after a table in the
HTML file, then the paragraph w ill move f urther down if the ta ble is made larger, and
will move up if the table shortens.
Technically, we control the element’s flow with the position property. This prop-
erty can take a couple of keyword values, of which we’ll stud y the values static,
absolute, and rela tive. The default value is static, which puts the element in
the normal flow.
Depending on the value o f the position property, we usually say that an ele ment is
absolutely positioned, relatively p ositioned, or not positioned, if the position prop-
erty is set to static. Absolutely and relatively p ositioned elements are of te n referred
to as positioned.
Let’s carry out a little experiment. Consider, for example, the following piece of
HTML code:
80 Meeting 5. Understanding CSS Boxes