HTML (Hypertext Markup Language) is the backbone of all websites. It is the language used to structure web pages and their content. HTML uses tags to define the structure of the page and to tell the browser how to display the content. In this tutorial, we’ll cover some of the most important HTML tags you need to know to create a web page.
Headings and Paragraphs
HTML has six levels of headings, from h1 (most important) to h6 (least important). Headings are used to structure the content and make it easier to read. To create a heading, use the h1 to h6 tags, followed by the text you want to display.
Example:
<h1>This is a Heading 1</h1> <h2>This is a Heading 2</h2> <h3>This is a Heading 3</h3> <p>This is a paragraph.</p>
Links
Links are used to connect web pages and allow users to navigate between them. To create a link, use the `<a>` tag and include the URL of the page you want to link to. You can also add a title attribute to provide a tooltip when the user hovers over the link.
Example:
<a href="https://www.example.com" title="Visit Example">Example Website</a>
Images
Images are used to add visual elements to a web page. To insert an image, use the `<img>` tag and include the source (src) attribute with the URL of the image. You can also add alt and title attributes to provide a description and tooltip for the image.
Example:
<img src="https://www.example.com/image.jpg" alt="A beautiful sunset" title="Sunset at the beach">
Lists
Lists are used to organize content into ordered or unordered lists. To create an ordered list, use the `<ol>` tag and include each item within the `<li>` tags. To create an unordered list, use the `<ul>` tag instead.
Example:
<ol> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ol> <ul> <li>Bullet 1</li> <li>Bullet 2</li> <li>Bullet 3</li> </ul>
Tables
Tables are used to display data in a structured format. To create a table, use the `<table>` tag and include the table rows within the `<tr>` tags. Each cell within the row should be wrapped in a `<td>` tag. You can also use the `<th>` tag to define a table header.
Example:
<table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>John</td> <td>25</td> </tr> <tr> <td>Jane</td> <td>30</td> </tr> </table>
Forms
Forms are used to collect user input, such as login details or search queries. To create a form, use the `<form>` tag and include form elements within it, such as `<input>` and `<textarea>` tags. You can also use the `<label>` tag to provide a label for each form element.
Example:
<form> <label for="name">Name:</label> <input type="text" id="name" name="name"><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br> <label for="message">Message:</label> <textarea id="message" name="message"></textarea><br> <input type="submit" value="Submit"> </form>
HTML5 Semantic Tags
HTML5 introduced a set of semantic tags that describe the content they contain. These tags help search engines and screen readers to better understand the structure of the page. Some of the most commonly used semantic tags include `<header>`, `<nav>`, `<main>`, `<section>`, `<article>`, and `<footer>`.
Example:
<header> <h1>Page Title</h1> <nav> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </nav> </header> <main> <section> <h2>Section Title</h2> <p>Section Content</p> </section> <section> <h2>Another Section Title</h2> <p>More Section Content</p> </section> </main> <footer> <p>Copyright © 2023</p> </footer>
Conclusion
In conclusion, these are some of the most important HTML tags you need to know to create a web page. By using these tags, you can structure your content, create links, add images, organize data in tables, and create forms. Additionally, HTML5 semantic tags can help to improve the accessibility and SEO of your web page.