HTML Elements, Tags, Attributes, Nesting, Comments and Entities: Block vs Inline Elements for Beginners

HTML5 and CSS3 45 min min read Updated: Nov 17, 2026 Beginner
HTML Elements, Tags, Attributes, Nesting, Comments and Entities: Block vs Inline Elements for Beginners
Beginner Topic 3 of 3

Anatomy of an Element

html <p class="intro">Hello <strong>world</strong></p>
PartExampleMeaning
Opening tag<p>Starts the element
Attributeclass="intro"Extra information as name and value
ContentHello worldWhat is inside
Closing tag</p>Ends the element

The whole thing, from opening tag to closing tag, is one element.

Void Elements

Some elements have no content and no closing tag. They are called void elements.

html <br> <hr> <img src="logo.png" alt="Company logo"> <input type="text" name="user"> <meta charset="utf-8">

Common Attributes

AttributeUse
idA unique name for one element on the page
classA reusable name for styling many elements
hrefLink destination
srcFile source for images, scripts and media
altText description of an image
titleExtra tooltip text
langLanguage of the content
Quotes Always put attribute values in quotes. It avoids bugs when a value has spaces.

Nesting

Elements go inside other elements. Close the inner element before the outer one.

html <!-- Correct --> <p>This is <em>important</em> text.</p> <!-- Wrong: the tags cross --> <p>This is <em>important</p></em>

Comments

html <!-- This note is not shown on the page --> <p>Visible text</p>

Character Entities

Some characters have special meaning in HTML. Use an entity to show them as text.

To showWriteName
<&lt;less than
>&gt;greater than
&&amp;ampersand
Non-breaking space&nbsp;space that does not wrap
Copyright sign&copy;copyright

Block vs Inline

Block elementsInline elements
Start onA new lineThe same line
WidthTake the full widthOnly as wide as the content
Examplesdiv, p, h1, ul, sectionspan, a, strong, em, img
html <div>I am a block. I take a full row.</div> <span>I am inline.</span> <span>I stay on the same line.</span>
Good to know Block and inline are default behaviors. CSS can change them with the display property, which you will learn later.

Practice

  1. Write a paragraph with one link and one bold word
  2. Show the text <h1> on a page using entities
  3. List three block and three inline elements

Conclusion

An element has tags, attributes and content. Nest tags correctly, use entities for special characters, and remember block elements take full rows while inline elements flow in text.

Quick Summary: Anatomy; void elements; attributes; nesting; comments; entities; block vs inline.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators