Lesson 5: Block and Inline Elements
Aim: How can we use block and inline elements to enhance HTML page layouts ?
- Understand html block and inline elements.
- Understand html classes.
- Create a HTML webpage layout of European cites.
- What are the two different types of element display ?
- How are block elements display?
- What are some examples of block elements?
- How are inline elements display?
- What are some examples of inline elements?
HTML Block and Inline Elements
Every HTML element has a default display value depending on what type of element it is. The default display value for most elements is block or inline.
A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
Examples of block-level elements:
- <h1> – <h6>
An inline element does not start on a new line and only takes up as much width as necessary.
This is an inline <span> element inside a paragraph.
Examples of inline elements:
The <div> Element
The <div> element is a block-level element that is often used as a container for other HTML elements.
The <div> element has no required attributes, but style and class are common.
When used together with CSS, the <div> element can be used to style blocks of content:
<div style=”background-color:Blue; color:white; padding:20px;”>
<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
<img style=”border: solid; 9px;” src=url.jpg alt= London/>
The <span> Element
The <span> element is an inline element that is often used as a container for some text.
The <span> element has no required attributes, but style and class are common.
When used together with CSS, the <span> element can be used to style parts of the text:
- Create a webpage title European Cities in H1 tags.
- Pick 3 famous cities within Europe.
- The title of each city should be h2 tags.
- The description of each city in paragraph tags.
- Add one image of each city.
- Add a link to reference the city resource description
Here is your first city below:
London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.
Create a HTML & CSS website with the following:
- background color
- color paragraph text