Block and Inline Elements (2024)

Back to Week 4 page »

In HTML 4.01, there were two basic categories of HTML elements:

  • Block level elements
  • Inline elements

Block Level Elements

Block level elements take up as much space as possible by default. Each block level element will start a new line on the page, stacking down the page. In addition to stacking vertically, block level elements will also take up as much horizontal space as possible.

The p element is an example of a block level element. Each new paragraph tag will appear on its own line vertically. Paragraphs with longer content will stretch all the way to the edge of the page.

Examples of block level elements:

  • <p>
  • <ol>, <ul>, <dl>
  • All headings
  • <article>, <section>, <div>

Demo

Inline Elements

Inline elements display in a line. They do not force the text after them to a new line.

An anchor (or link) is an example of an inline element. You can put several links in a row, and they will display in a line.

Examples of inline elements:

  • <a>
  • <strong>, <em>, <b>, <i>, <q>, <mark>
  • <span>

Demo

See it all together

Why is this important?

How an element behaves when styled with CSS will change based on the display mode of an element (block vs. inline). Some CSS properties react differently for each display type. We'll learn more about this behavior when we start to lay out pages in CSS.

For now, remember this:

  • Inline elements cannot contain block level elements

For example, you cannot wrap an <em> around two paragraphs:

<em>← Incorrect <p>An emphasized paragraph.</p> <p>Another emphasized paragraph.</p></em>← Incorrect
The correct way to do this would be to put the inline element inside each block element:
<p><em>An emphasized paragraph.</em></p><p><em>Another emphasized paragraph.</em></p>

One Exception (New in HTML5)

HTML5 creates one welcome exception to this rule. You can now wrap links around block level elements. An example makes this clear.

It's common to mark up the name of the site with a logo and tag line, something like this:

<h1>Recipe Book</h1><p>Eat first, talk later.</p>

Typically, each of these would also link to the home page. Previously, you would mark up each block-level element with a link

<h1><a href="index.html">Recipe Book</a></h1><p><a href="index.html">Eat first, talk later.</a></p>

Now you can simply wrap both in a link. Cleaner and less redundant.

<a href="index.html"> <h1>Recipe Book</h1> <p>Eat first, talk later.</p></a>

Back to Week 4 page »

Block and Inline Elements (2024)
Top Articles
How to Ensure Your Money Transfer Is Safe and Trackable from the US - Vance
What is the ideal AC temperature to save electricity bills? | - Times of India
Devon Lannigan Obituary
Archived Obituaries
Top Scorers Transfermarkt
Nfr Daysheet
Mileage To Walmart
Truist Park Section 135
Us 25 Yard Sale Map
Pickswise the Free Sports Handicapping Service 2023
Optimal Perks Rs3
Volstate Portal
Soap2Day Autoplay
ATV Blue Book - Values & Used Prices
Dumb Money
United Dual Complete Providers
Erskine Plus Portal
272482061
Price Of Gas At Sam's
Canvas Nthurston
Petco Vet Clinic Appointment
20 Different Cat Sounds and What They Mean
Shopmonsterus Reviews
Georgia Cash 3 Midday-Lottery Results & Winning Numbers
Melendez Imports Menu
Jail View Sumter
Farm Equipment Innovations
Craigslist Northern Minnesota
What we lost when Craigslist shut down its personals section
Darknet Opsec Bible 2022
Craigslist Cars And Trucks Mcallen
Persona 4 Golden Taotie Fusion Calculator
#scandalous stars | astrognossienne
Appraisalport Com Dashboard /# Orders
Does Iherb Accept Ebt
Tirage Rapid Georgia
888-333-4026
Miracle Shoes Ff6
Shane Gillis’s Fall and Rise
2007 Jaguar XK Low Miles for sale - Palm Desert, CA - craigslist
Nina Flowers
Coffee County Tag Office Douglas Ga
Reilly Auto Parts Store Hours
Skyward Cahokia
Conan Exiles Colored Crystal
Actress Zazie Crossword Clue
Horseneck Beach State Reservation Water Temperature
Craiglist.nj
Msatlantathickdream
Sml Wikia
What your eye doctor knows about your health
Southern Blotting: Principle, Steps, Applications | Microbe Online
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6146

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.