HTML stands for HyperText Markup Language. It is the standard language used to create web pages and web applications. HTML provides the structure and content of a webpage, while other technologies like CSS and JavaScript handle styling and interactivity.
Think of HTML as the skeleton of a webpage: it defines what content exists (like headings, paragraphs, images, links), while CSS adds style and JavaScript adds behavior.
Key Concepts
-
Elements & Tags
HTML uses tags to define elements. Tags are enclosed in angle brackets< >. Most elements have an opening tag and a closing tag:
<p>This is a paragraph.</p>
Here:
-
<p>is the opening tag -
</p>is the closing tag -
The text in between is the content
-
Common HTML Elements
| Element | Purpose | Example |
|---|---|---|
<h1> to <h6> |
Headings (h1 = largest) | <h1>Welcome to HTML</h1> |
<p> |
Paragraph | <p>This is a paragraph.</p> |
<a> |
Link | <a href="https://example.com">Visit Example</a> |
<img> |
Image | <img src="image.jpg" alt="My Image"> |
<ul> / <ol> |
Lists | <ul><li>Item 1</li></ul> |
<div> |
Division / container | <div>Content here</div> |
<span> |
Inline container | <span>Text here</span> |
-
Attributes
Attributes provide additional information about an element. They are added inside the opening tag:
<a href="https://example.com" target="_blank">Visit Example</a>
<img src="logo.png" alt="Logo" width="100">
-
hrefspecifies the link URL -
target="_blank"opens the link in a new tab -
srcspecifies the image source -
altprovides alternative text
-
HTML Document Structure
A basic HTML page looks like this:
<!DOCTYPE html>
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a simple web page.</p>
</body>
</html>
-
<!DOCTYPE html>: Declares the document type -
<html>: Root element -
<head>: Contains meta information (title, styles, scripts) -
<body>: Contains visible content of the webpage
Why HTML is Important
-
Provides the structure of web content
-
Makes web pages accessible to browsers and search engines
-
Works with CSS and JavaScript to create interactive and visually appealing website.