What is HTML?
HTML stands for HyperText Markup Language. It's the standard markup language for creating web pages. Let's break that down:
- HyperText: Refers to text with hyperlinks! These links connect you to other documents or resources on the web. Think of clicking a word or phrase and being taken to a new page.
- Markup Language: HTML isn't a programming language; it's a markup language. This means it uses tags to mark up text, telling the web browser how to display the content. It describes the structure of the content, not what the content does.
- Language: It has a specific syntax (rules) that you need to follow for it to work correctly.
In simpler terms:
Imagine you're writing a letter. You use paragraphs, headings, and maybe bold or italic text to organize your thoughts. HTML does the same thing for web pages. It provides the structure and formatting for the content you want to display.
How does it work?
HTML uses elements defined by tags.
- Tags: These are keywords enclosed in angle brackets (
< >). Most tags come in pairs: an opening tag and a closing tag.<p>is an opening tag for a paragraph.</p>is the closing tag for a paragraph.
- Elements: An HTML element consists of the opening tag, the content, and the closing tag. For example:
<p>This is a paragraph.</p>
Example:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph of text.</p>
<a href="https://www.example.com">Visit Example.com</a>
</body>
</html>
What does this code do?
<!DOCTYPE html>: Tells the browser this is an HTML5 document.<html>: The root element of the page. Everything else goes inside this.<head>: Contains meta-information about the HTML document, such as the title. This isn't displayed on the page itself.<title>: Specifies a title for the HTML page (which is shown in the browser's title bar or tab).<body>: Contains the visible page content.<h1>: Defines a level 1 heading (the largest heading).<p>: Defines a paragraph.<a>: Defines a hyperlink. Thehrefattribute specifies the URL the link points to.
Key Takeaways:
- HTML provides the structure of a web page.
- It uses tags and elements to define content.
- It's the foundation of almost every website you see.