Tutorial Playlist
The modern world relies heavily on the internet for everything. Whether ordering groceries, looking up services, or seeking a doctor’s appointment, almost everything can be done online. This underscores the growing demand for web development jobs. As a web developer with over a decade of experience, I can guarantee that learning basic HTML is a crucial step to building a career in this sector. HTML examples can help you learn the language better and help you build interactive and well-organized websites.
I’ve crafted this tutorial to help you navigate the basic concepts of HTML using HTML example programs.
To make your web page more visually engaging, you can opt to color your text. We will look at the different types of color codes you can use to color your text with the help of sample HTML examples.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Fonts Example</title>
</head>
<body>
<h1 style="color: blue;">This is a heading in blue</h1>
<h2 style="color: #89da98;">This is a heading in light green</h2>
<h3 style="color: rgb(255, 3, 255);">This is a heading in pink</h3>
<p style="color: #ab4411;">This is a paragraph in brown</p>
<p style="color: rgb(255, 0, 255);">This is a paragraph in magenta</p>
<p style="color: hsl(120, 100%, 50%);">This is a paragraph in lime</p>
</body>
</html>
All the headings and paragraphs use different types of color codes. The types of color codes used in the above example are:
Another important type of element commonly found in webpages is tables. They are commonly used when we want to showcase a lot of data in a systemic and concise manner. Here, we will look at some sample HTML examples of table usage.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Table Example</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}
</style>
</head>
<body>
<h2> HTML Table Example (Schedule of an Event) </h2>
<table border="1" cellpadding="5" cellspacing="0">
<caption>Monthly Expenses</caption>
<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Category</th>
<th scope="col">Performaces</th>
</tr>
</thead>
<tbody>
<tr>
<td>2023-01-05</td>
<td>Rock</td>
<td>Eagles</td>
</tr>
<tr>
<td>2023-01-10</td>
<td> Blues</td>
<td> John Mayer</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2" align="right">2023-01-11</td>
<td> N.A. </td>
</tr>
</tfoot>
</table>
</body>
</html>
In this simple HTML example of a table, <tfoot> and <thead> tags are used for giving the footer and heading to the table.
Here, let me talk about the attributes used in this example:
The concept of div is very important in HTML. Here are some key pointers about it.
Let me demonstrate <div> tag usage in HTML with an example.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Div Tag Example in HTML</title>
<style>
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
background-color: #acf0f0;
border: 1px solid #ccc;
}
.box {
width: 100px;
height: 100px;
background-color: #ad0000;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>Div Tag Example</h1>
<p>This is an example of using the div tag in HTML.</p>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</body>
</html>
Here, we have created one parent div, which inherits the properties of the class container. This div houses an h1 element, a paragraph element, and three div elements. The daughter elements inherit properties of the box class.
I am sure you are accustomed to filling out registration forms online. Here, I will explain how to create one using this HTML example template.
Code:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
.container {
max-width: 400px;
margin: 0 auto;
background-color: #ADD8E6;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
.btn {
background-color: #4CAF50;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.btn:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>Registration Form Example</h2>
<form>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<div class="form-group">
<label for="confirm-password">Confirm Password:</label>
<input type="password" id="confirm-password" name="confirm-password" required>
</div>
<div class="form-group">
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" required>
</div>
<div class="form-group">
<input type="submit" value="Register" class="btn">
</div>
</form>
</div>
</body>
</html>
In this example of registration form HTML example program, there are four fields where input is required from the user's side. They are username, date of birth, password, and email. We have styled the main div with CSS, giving it a nice light blue background color. We have also used a hover effect on the submit button where it changes color when the user's cursor is hovering over the button.
Hyperlinking basically means linking an HTML element to another web page. HTML elements like text, images, and GIFs can be hyperlinked. Now, let us look at how we can hyperlink HTML examples with source code for each element one by one.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Heading Hyperlink Example</title>
</head>
<body>
<h1><a href="https://www.example.com"> This Heading is Hyperlinked. Click here.</a></h1>
<p> This is a paragraph below the heading which is not hyperlinked. </p>
</body>
</html>
The above code clearly shows that the heading element “This Heading is Hyperlinked” is hyperlinked to the website https://www.example.com.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Paragraph Hyperlink Example</title>
</head>
<body>
<p>This is a paragraph which is not hyperlinked. <a href="https://www.example.com">This part is hyperlinked.</a></p>
<p>Another paragraph below the hyperlink which is not hyperlinked.</p>
</body>
</html>
In the above HTML example website, it is evident that the part of the paragraph that says “This part is hyperlinked” is linked to https://www.example.com.
HTML is definitely a valuable skill to have in your arsenal. Although the scope of HTML programming is vast, we can aim to study it effectively. HTML examples are a great place to learn from and improve your skills. We have discussed different HTML examples in this tutorial. However, you choose your own HTML examples for practice.
The HTML examples in this tutorial can be only used as a reference and while that helps, it is always better to learn the more complex topics from a certified course. I would recommend checking out courses from upGrad. Their courses are certified and are in collaboration with some of the best universities around the world. Their courses are curated by the best faculty around in this field.
HTML, or HyperText Markup Language, is a coding language for creating web pages. It uses tags to organize content and define elements on a website. Here is a simple HTML example:
<!DOCTYPE html>
<html>
<head>
<title> HTML Web page Example </title>
</head>
<body>
<h1>Welcome to my website!</h1>
<p>This is a paragraph of text.</p>
<a href="https://www.example.com"> Click here to visit Example </a>
</body>
</html>
There are many HTML sample templates available to help you get started on developing web pages. These templates provide pre-defined structures and styles that can be customized to meet your specific needs.
To create code examples in HTML. Use the <code> tag to insert code snippets into paragraphs. Use the <pre> tag to show preformatted code blocks with whitespace and line breaks retained.
Creating a website using an HTML example entails numerous steps, including establishing the HTML framework, adding content, styling with CSS, and potentially adding interaction with JavaScript.
HTML examples are important because they help you learn coding in an easy and efficient manner. They serve as a template and show industry standard best practices.
Short HTML examples can be found on websites such as W3Schools, MDN Web Docs, Bootstrap's documentation, GitHub repositories, and a variety of web development tutorials and forums.
Some common HTML examples include creating links, adding images, using headings, creating lists, inserting paragraphs, and adding forms.
You can use HTML examples to start learning effectively. You can go see documentation, see how industry-standard code is written, and notice best practices.
Rohan Vats
Talk to our experts. We’re available 24/7.
Indian Nationals
1800 210 2020
Foreign Nationals
+918045604032
upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enrolling. upGrad does not make any representations regarding the recognition or equivalence of the credits or credentials awarded, unless otherwise expressly stated. Success depends on individual qualifications, experience, and efforts in seeking employment.
upGrad does not grant credit; credits are granted, accepted or transferred at the sole discretion of the relevant educational institution offering the diploma or degree. We advise you to enquire further regarding the suitability of this program for your academic, professional requirements and job prospects before enr...