HTML, or HyperText Markup Language, is a markup language used to create web pages and applications on the internet. It defines the structure of a web page by using tags, which are enclosed in angle brackets and contain information about how the content should be displayed.
HTML is a declarative language, which means that the developer specifies what they want the web page to look like, and the browser handles the details of how to display it.
HTML elements are composed of several parts, including:
- Start tag: The opening tag that begins the element and includes the name of the element.
- End tag: The closing tag that ends the element and includes a forward slash (/) before the name of the element.
- Content: The text, images, or other media that appears between the start and end tags.
- Attributes: Optional attributes that provide additional information about the element, such as its size, color, or alignment.
Here’s an example of an HTML element that displays an image on a web page:
<img src="image.jpg" alt="A beautiful sunset">
In this example, the
<img> element is used to display an image on the web page. The
src attribute specifies the location of the image file, and the
alt attribute provides alternative text that is displayed if the image cannot be loaded.
Let’s take a closer look at an example of HTML code:
<!DOCTYPE html> <html> <head> <title>My Webpage</title> </head> <body> <h1>Welcome to my webpage</h1> <p>This is my first webpage.</p> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> </body> </html>
This code creates a simple webpage with a title, a heading, some text, and a bulleted list. Let’s break it down:
<!DOCTYPE html>: This is the document type declaration. It tells the browser which version of HTML is being used (in this case, HTML5).
<html>: This tag indicates the start of the HTML document.
<head>: This tag contains information about the document that is not displayed on the page, such as the title.
<title>: This tag sets the title of the page, which is displayed in the browser tab or window title bar.
</head>: This tag indicates the end of the head section.
<body>: This tag contains the visible content of the page.
<h1>: This tag creates a heading with the text “Welcome to my webpage”.
<p>: This tag creates a paragraph of text.
<ul>: This tag creates an unordered list.
<li>: This tag creates a list item.
As you can see, HTML is made up of a series of tags that define the structure and content of the page. By combining these tags in different ways, developers can create complex and dynamic web pages and applications.