learn2kode.in

HTML Basics

Introduction

HTML Basics cover the fundamental building blocks of every web page. You’ll learn how to use tags, elements, and attributes to create simple and well-structured web pages.

 An HTML element is everything from the start tag to the end tag.

Example Code

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

Output

Nested Elements

Elements can be nested — one element inside another.

Example Code

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

Output

This is a bold word inside a paragraph.

Headings are defined with <h1> to <h6> tags.
<h1> is the largest heading, and <h6> is the smallest.

Example Code

<h1>This is Heading 1</h1>
<h2>This is Heading 2</h2>
<h3>This is Heading 3</h3>

Output

This is Heading 1
This is Heading 2
This is Heading 3

Paragraphs are defined with the <p> tag.

<p>HTML is easy to learn and fun to use!</p>
<p>Start learning HTML with Learn2Kode tutorials.</p>

Output

HTML is easy to learn and fun to use!
Start learning HTML with Learn2Kode tutorials.

Links are defined with the <a> tag.
Use the href attribute to specify the destination URL.

Example Code

<a href="https://www.learn2kode.com">Visit Learn2Kode</a>

Output

Images are displayed using the <img> tag.
It has attributes like src, alt, width, and height.

Example Code

<img src="https://via.placeholder.com/150" alt="Sample Image" width="150">

Output

HTML Line Breaks and Horizontal Lines

Use <br> to break a line and <hr> to create a horizontal rule.

Example Code

<p>Learn HTML<br>Step by Step</p>
<hr>
<p>Keep practicing daily!</p>

Output

Comments are used to explain code and are ignored by the browser.

Example Code

<!-- This is a comment -->
<p>This line will be visible in the browser.</p>

Output

This line will be visible in the browser.