Web Design: html block elements

The tutor discusses html block elements.

Block elements, in their native state, occupy the entire line. Therefore, each appears on its own.

Because it occupies the whole line, a block element’s text can, in my experience, be centered using text-align:

<p style=”background-color:Lavender;text-align:center;font-size:120%”>Hello</p>


A block element’s width can be set less than the whole line. Then, it can (usually) be centered using margin:auto as shown:

<div style=”background-color:bisque;text-align:center;font-size:120%;width:60%; margin:auto”>Hello</div>


Some examples of html block elements are p, div, and table.

The “other” type of html element, besides block, is inline. I’ll be talking more about them in future posts:)

Source:

Mozilla foundation

w3schools

dev.w3.org

w3schools

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply