HTML, or HyperText Markup Language, is the standard markup language used to create web pages. HTML allows web designers and developers to structure and format the content of a web page using tags. In this article, we'll take a closer look at HTML tags, including what they are, how they work, and some of the most commonly used tags.
What are HTML tags?
HTML tags are elements that are used to structure and format content on a web page. They are surrounded by angle brackets, < >, and are usually composed of a tag name and attributes. For example, the <h1> tag is used to define a heading, and the attribute "class" can be used to assign a class to the heading.
How do HTML tags work?
HTML tags are used to define different parts of a web page, such as headings, paragraphs, links, images, and tables. The browser reads the HTML code and uses the tags to display the content of the web page. The browser knows how to interpret the tags based on the HTML specification, which defines the meaning and behavior of each tag.
HTML tags can also be used to add attributes to elements. Attributes provide additional information about an element, such as its size, color, or alignment. For example, the <img> tag is used to display an image, and the "src" attribute is used to specify the URL of the image file.
Commonly used HTML tags
Here are some of the most commonly used HTML tags:
<html> - Defines the start of an HTML document
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</body>
</html>
<head> - Contains information about the web page, such as the title and meta tags
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="description" content="This is an example web page." />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</body>
</html>
<title> - Defines the title of the web page
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</body>
</html>
<body> - Contains the visible content of the web page
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</body>
</html>
<h1> to <h6> - Define headings of different sizes
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<h2>About Us</h2>
<p>This is an example paragraph.</p>
</body>
</html>
<p> - Defines a paragraph
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</body>
</html>
<a> - Defines a hyperlink
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>Visit our <a href="https://www.example.com/">website</a> for more information.</p>
</body>
</html>
<img> - Displays an image
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<img src="image.jpg" alt="Example Image" />
</body>
</html>
<ul> - Defines an unordered list
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
<li>List Item 4</li>
<ul>
</body>
</html>
<ol> - Defines an ordered list
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<ol>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ol>
</body>
</html>
<li> - Defines a list item
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Welcome to my website!</h1>
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
</body>
</html>
<div> - Defines a division or section of a web page.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="container">
<h1>Welcome to my website!</h1>
<p>This is an example paragraph.</p>
</div>
</body>
</html>
<span> - Defines a small section of text within a larger block of text.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>This is an example <span>span</span> of text.</p>
</body>
</html>
<form> - Defines a form for user input.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<input> - Defines an input field for a form.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<textarea> - Defines a multi-line input field for a form.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<form>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" cols="50"></textarea><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<select> - Defines a drop-down list for a form.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<form>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="mexico">Mexico</option>
</select><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
<button> - Defines a clickable button.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button>Click me!</button>
</body>
</html>
<table> - Defines a table
<thead> - Defines the header section of a table.
<tbody> - Defines the body section of a table.
<tr> - Defines a table row
<td> - Defines a table cell
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Jane</td>
<td>Doe</td>
<td>jane@example.com</td>
</tr>
</tbody>
</table>
</body>
</html>
<nav> - Defines navigation links
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<header> - Defines a header section of a web page.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<header>
<h1>Welcome to my website!</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
</body>
</html>
<footer> - Defines a footer section of a web page.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<header>
<h1>Welcome to my website!</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main>
<p>This is the main content of the web page.</p>
</main>
<footer>
<p>© 2023 Example Website. All rights reserved.</p>
</footer>
</body>
</html>
These are just a few examples of the many HTML tags that are available. Each tag has a specific purpose and can be used to create different types of content on a web page.
Conclusion
HTML tags are an essential part of web development. They allow web designers and developers to structure and format the content of a web page, making it easier for users to read and navigate. By understanding the basics of HTML tags, you can create more effective and engaging web pages that are optimized for both humans and search engines.
Komentar
Posting Komentar