Learn HTML
Lesson 2 - HTML Tags And Elements
Lesson 3 - Images And Multimedia
Lesson 4 - Writing Your First HTML Page
Lesson 5 - Overview Of CSS
Lesson 6 - CSS Selectors And Properties
Lesson 7 - Applying CSS To HTML
Lesson 8 - Box Model
Lesson 9 - Positioning And Layout
Lesson 10 - Flexbox
The fundamental components of HTML are Tags and Attributes which are used to structure and define content on web pages.
HTML tags are enclosed in angle brackets (< >
) and define the structure of the content. They come in pairs: an opening tag (<tag>
) and a closing tag (</tag>
). Tags can be nested to create hierarchical structures, and they determine how content is displayed or interpreted by browsers. Examples include <h1>
for headings, <p>
for paragraphs, <a>
for links, etc.
Let's have a look at an example of paragraph:
<p>Hi There!</p>
Now let's try creating paragraph in editor below. The content should say Hello World!
:
regex:/Hello World!/g <!-- Write Code Here --->
HTML attributes provide additional information about HTML elements. They are always included in the opening tag and are written as name-value pairs, separated by equals signs (=
) and enclosed in double quotes ("
). Attributes can modify the behaviour or appearance of elements, such as setting links (href
attribute in <a>
tag) or specifying image sources (src
attribute in <img>
tag).
Example:
<a href="https://example.com">Click here</a> <img src="image.jpg" alt="Description of image">
In the example above, href
and src
are attributes that provide essential details about the link and image elements, respectively.
An HTML document follows a specific structure that ensures proper rendering and functionality in web browsers. Let's break it down:
<!DOCTYPE html>
<html>
<html>
tag is the root element of every HTML page. It encapsulates all other elements and defines the document as an HTML document.<head>
<html>
tag, the <head>
section contains meta-information about the document, such as its title, character encoding, and references to external resources like stylesheets or scripts.<title>
<title>
tag, nested within <head>
, sets the title of the webpage. This title appears in the browser's title bar or tab, helping users identify the page.<body>
<body>
tag encloses the content of the webpage that users see and interact with. This includes text, images, links, forms, and other elements that make up the visible part of the webpage.<!DOCTYPE html> <html> <head> <title>My First HTML Page</title> </head> <body> <h1>My First Website</h1> <p>This is my first paragraph. I'm learning HTML!</p> </body> </html>
In this example:
<title>
element defines the title displayed in the browser.<h1>
and <p>
elements represent heading and paragraph content within the <body>
.Understanding this structure is essential for creating well-formed HTML documents that display correctly across different browsers and devices.