#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
HTML Fundamentals

HTML Basics

HTML basics cover the minimum structure every web page needs and the handful of elements you will use on almost every page: headings, paragraphs, links, images and lists. HTML describes what each piece of content is; the browser reads that description and builds the page. Styling comes later with CSS, and behaviour with JavaScript.

The skeleton of every page

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My First Page</title>
  </head>
  <body>
    <h1>Hello, web!</h1>
    <p>This is my first paragraph.</p>
    <a href="https://developer.mozilla.org">Read the HTML docs</a>
    <img src="images/cat.jpg" alt="A grey cat asleep on a sofa" width="400" height="300">
    <ul>
      <li>HTML for structure</li>
      <li>CSS for style</li>
      <li>JavaScript for behaviour</li>
    </ul>
  </body>
</html>

Line by line:

  • <!DOCTYPE html> tells the browser to use standards mode. Leaving it out triggers older quirks mode, where layouts behave unpredictably.
  • <html lang="en"> wraps everything and declares the language, which helps screen readers and translation tools.
  • <head> holds information about the page that is not shown directly: character set, viewport settings, the title shown in the browser tab, and later links to CSS.
  • <body> holds everything visitors actually see.

Tags, elements and attributes

A tag is the text in angle brackets. Most elements have an opening tag and a closing tag with a slash, and content in between: <p>Text</p>. Some elements, such as <img>, <br> and <meta>, are void elements: they have no content and no closing tag.

Attributes add extra information inside the opening tag as name and value pairs. href tells a link where to go, src tells an image which file to load, and alt provides a text description. Put attribute values in double quotes.

The elements you will use daily

ElementUsed for
<h1> to <h6>Headings, from the main title down to small subheadings.
<p>A paragraph of text.
<a>A link to another page, file or section.
<img>An image.
<ul>, <ol>, <li>Bulleted and numbered lists and their items.

Use headings in order, one <h1> for the page title, then <h2> for sections and <h3> inside those. Pick headings for meaning, not size; CSS controls size.

Nesting correctly

Elements sit inside one another like boxes. Whatever opens last must close first. <p><strong>Bold</strong></p> is correct; <p><strong>Bold</p></strong> is not. Browsers try to repair broken nesting, but they guess, and the guess may differ from what you meant.

Beginner slips to avoid

  • Missing or empty alt text on meaningful images leaves screen reader users with nothing. Describe what the image shows. Use alt="" only for purely decorative images.
  • Wrong file paths. src="images/cat.jpg" is relative to the HTML file. If the image is not showing, check the folder name and letter case; many servers treat Cat.JPG and cat.jpg as different files.
  • Spaces and line breaks in your code collapse into a single space on screen. Use separate paragraphs rather than pressing Enter many times.
  • Saving with the wrong extension. The file must end in .html, and the home page is usually named index.html.

Try it yourself

Save the skeleton above as index.html, open it in a browser, change the heading and add a second list item. Then right-click the page and choose View Page Source to compare what you wrote with what the browser shows. These few elements and the doctype, head and body structure are the foundation every later HTML topic builds on.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course