HTML (HyperText Markup Language) is the core language used to create and structure content on the web. It defines the structure of web pages, and along with CSS and JavaScript, powers the interactive web we know today.
1. What is HTML?
HTML defines the structure of web pages using a series of tags that tell the browser how to display content. For example, text is enclosed in <p>
tags, and images are defined with <img>
.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First HTML Page</title>
</head>
<body>
<h1>Welcome</h1>
<p>HTML basics</p>
</body>
</html>
2. HTML Evolution
HTML has evolved through several versions, with HTML5 being the most widely used today. HTML5 added new tags for better structure and accessibility.
3. Basic Structure
Every HTML document starts with the <!DOCTYPE html>
declaration, followed by <html>
, <head>
, and <body>
elements.
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>Header</h1>
<p>Text</p>
</body>
</html>
4. HTML Tags and Attributes
HTML elements are defined by tags, and attributes provide additional information. For example, the src
attribute specifies the source of an image.
<img src="image.jpg" alt="Description">
5. Semantic HTML
HTML5 introduced semantic elements like <header>
, <footer>
, and <article>
, which improve readability and SEO.
<header>Header</header>
<footer>Footer</footer>
<article>Content</article>
6. Forms
Forms allow users to interact with your website by submitting data. They are created with the <form>
tag.
<form>
<label>Name</label>
<input type="text">
<button>Submit</button>
</form>
7. Best Practices for SEO and Accessibility
- Use semantic tags to improve structure and SEO.
- Ensure text contrasts sufficiently with the background.
- Always include
alt
text for images to improve accessibility.
8. HTML and CSS
While HTML defines structure, CSS styles the content. Here’s how HTML and CSS work together:
<style>
body { background-color: #333; color: white; }
h1 { color: red; }
</style>
9. Conclusion
HTML is the backbone of the web, enabling developers to build functional and accessible websites. Combined with CSS and JavaScript, it creates dynamic and engaging user experiences.