HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Elements & Attributes

HTML Basics

HTML Elements & Attributes

HTML pages are built using elements - the building blocks of a web page.
Each element defines a specific part of the content such as headings, paragraphs, images, or links.
Elements often include attributes that provide extra information about that element.

What Is an HTML Element?

An HTML element is everything between a start tag and an end tag.

Example

html

<p>This is a paragraph.</p>

In this example:

  • <p> → Start tag
  • </p> → End tag
  • This is a paragraph → Content
  • The entire line → HTML element

So, an element = start tag + content + end tag

HTML Element Syntax

Each HTML element usually follows this pattern:

html

<opening-tag>Content goes here</closing-tag>

Example

html

<h1>Hello World!</h1>

Here <h1> is the start tag, and </h1> is the closing tag.

Some elements don’t have content and don’t require a closing tag - these are called empty (void) elements.

Void Elements Example

html

<br>
<img src="image.jpg" alt="My Image">
<hr>

Types of HTML Elements

  1. Block-level elements - Start on a new line and take up full width.
    Examples: <div>, <h1>, <p>, <table>, <form>
  2. Inline elements - Do not start on a new line and only take up as much width as needed.
    Examples: <span>, , <strong>, <em>, <img>

What Are HTML Attributes?

Attributes provide extra details about an element - such as its behavior, appearance, or linked data.
They always appear inside the opening tag and are written as name="value" pairs.

Example

html

<a href="https://html5andcss3.org">Visit Our Site</a>

Example Explained:

  • a → Element
  • href → Attribute name
  • https://html5andcss3.org → Attribute value

Common HTML Attributes

AttributeDescriptionExample
idSpecifies a unique identifier for an element<p id="intro">Welcome</p>
classGroups elements for styling or scripting<div class="box"></div>
styleAdds inline CSS styling<p style="color:blue;">Hello</p>
titleAdds tooltip textHTML
srcSpecifies the source of an image or media<img src="logo.png">
hrefDefines link destinationLink
altAdds alternate text for images<img src="photo.jpg" alt="Nature view">

Attribute Rules

  • Attributes are written inside the opening tag.
  • Always use lowercase names for attributes.
  • Always enclose values in quotes (single or double).
  • You can use multiple attributes inside one tag.

Example

html

<img src="pic.jpg" alt="My Photo" width="400" height="300">

Nesting HTML Elements

Elements can be placed inside other elements - this is called nesting.

Example

html

<p>This is a <strong>bold</strong> word inside a paragraph.</p>

Here <strong> is nested inside <p>.
Always close nested tags in the reverse order they are opened.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

Conclusion

HTML elements define the structure, and attributes define the behavior and properties of those elements.
Mastering both is essential to build well-structured, accessible, and dynamic web pages.

PreviousHTML StructureNextHTML Headings