MyInternships.in

HTML Basics

HTML Basics

Once you understand a handful of core ideas — tags, elements, attributes, and page structure — the rest of HTML falls into place. This page covers those fundamentals with examples you can run.


What are the HTML Basics?

An HTML document is built from elements. An element is usually an opening tag, some content, and a closing tag. For example, <h1>Welcome</h1> is a heading element where <h1> opens it, Welcome is the content, and </h1> closes it.

Tags can also carry attributes that provide extra information, written inside the opening tag as name="value" pairs. A few elements, called empty or void elements, have no content and no closing tag — such as <br> and <img>.

Basic Usage

Element with an attribute
Example
<a href="https://myinternships.in">Find internships</a>

Example: The Standard Document Structure

Every page follows this pattern
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML Basics</title>
</head>
<body>
  <h1>Main heading</h1>
  <p>A paragraph with a <a href="#">link</a> inside it.</p>
  <img src="https://picsum.photos/200" alt="A placeholder image">
</body>
</html>

More Examples

Nesting elements inside each other
Example
<p>You can put <strong>bold</strong> and <em>italic</em> text inside a paragraph.</p>
<ul>
  <li>List item one</li>
  <li>List item <strong>two</strong></li>
</ul>
Empty (void) elements have no closing tag
Example
<p>First line of text.<br>Second line after a line break.</p>
<hr>
<p>A horizontal rule sits above this line.</p>

The Parts of an Element

PartExampleDescription
Opening tag<p>Marks where the element starts.
ContentHelloThe text or elements inside.
Closing tag</p>Marks where the element ends.
Attributehref="..."Extra info placed in the opening tag.
💡

HTML tag names are not case sensitive, but the convention is to write them in lowercase. This keeps your code consistent and readable.

⚠️

Always close the tags that need closing and nest them correctly. Writing <p><strong>text</p></strong> is wrong — inner elements must close before outer ones.

Key Takeaways

  • An element = opening tag + content + closing tag.
  • Attributes add extra information inside the opening tag.
  • Void elements like <br>, <hr> and <img> have no closing tag.
  • Elements must be nested and closed in the correct order.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships