Welcome to the HTML Language Codes tutorial! In this lesson, we'll delve into the world of HTML, learning how to structure web pages using its various elements. Whether you're a complete beginner or an intermediate learner, this guide will provide you with a solid foundation to master HTML.
HTML, or Hyper Text Markup Language, is the standard language used to create web pages. HTML elements are used to structure content on web pages, making them easy for both humans and machines to understand.
Every HTML document begins with a <!DOCTYPE> declaration and an <html> element. Within the <html> element, you'll find the <head> and <body> sections.
<!DOCTYPE html>
<html>
<head>
<!-- Meta data and other elements go here -->
</head>
<body>
<!-- Main content goes here -->
</body>
</html>The <head> section contains meta information about the document, such as its title, character encoding, styles, and scripts.
<head>
<title>My First HTML Page</title>
</head>The <body> section contains the main content of your web page. This is where you'll place your headings, paragraphs, images, and other elements.
<body>
<h1>Welcome to My First HTML Page!</h1>
<p>This is an example paragraph.</p>
</body>HTML elements are defined by starting and ending tags (e.g., <h1> and </h1>), and you can add attributes to modify their behavior.
<a href="https://www.codeyourcraft.com" target="_blank">Visit CodeYourCraft</a>In the example above, the <a> tag creates a link. The href attribute specifies the URL of the linked page, while the target attribute determines how the linked page should open (in the same or a new tab).
Here's a list of commonly used HTML tags, along with their purposes and examples.
<h1> - Heading 1 (largest heading)<h2> - Heading 2<h3> - Heading 3<h4> - Heading 4<h5> - Heading 5<h6> - Heading 6 (smallest heading)<h1>Main Heading</h1>
<h2>Secondary Heading</h2>
<!-- ... --><p> - Paragraph<br> - Line break<a> - Anchor (link)<span> - Inline container for styling (not supported in older browsers)<p>This is a paragraph.</p>
<br>
<a href="https://www.codeyourcraft.com">Visit CodeYourCraft</a>
<span style="color: red;">This text is red.</span><div> - Division (a generic container)<section> - Section of the document (for organizing content)<article> - Independent content (such as blog posts or news articles)<header> - Header of the document or section (contains a logo, navigation, and title)<footer> - Footer of the document or section (contains copyright and links)<nav> - Navigation (contains a list of links for navigation)<div>
<header>
<h1>Site Logo</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<!-- ... -->
</ul>
</nav>
</header>
<!-- ... -->
<footer>
<p>Ā© 2022 CodeYourCraft. All rights reserved.</p>
</footer>
</div>HTML forms allow users to interact with your web page by collecting input.
<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<input type="submit" value="Submit">
</form>There are two types of lists in HTML: unordered lists (<ul>) and ordered lists (<ol>).
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>What is the purpose of the `<h1>` tag in HTML?
Create an HTML document with a header, navigation, main content, and footer. Add a heading, a paragraph, a link, and a list to the main content.
<!DOCTYPE html>
<html>
<head>
<title>My Practice Exercise</title>
</head>
<body>
<header>
<h1>My Practice Exercise</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<!-- ... -->
</ul>
</nav>
</header>
<main>
<h2>Main Content</h2>
<p>This is an example of main content in an HTML document.</p>
<a href="https://www.codeyourcraft.com">Visit CodeYourCraft</a>
<h3>Unordered List</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</main>
<footer>
<p>Ā© 2022 My Practice Exercise. All rights reserved.</p>
</footer>
</body>
</html>