Tutorial Playlist
One of the most fundamental concepts I have learned in my journey as a web developer is HTML elements. HTML elements are used to create the structure of the website, and each serves a different purpose.
With this tutorial I’d attempt to give you a basic idea about HTML elements and attributes.
One of the first things you will realize when learning HTML programming is that the web page you develop in HTML is not one body but many small portions. Let me explain with an example.
Take the example of a car. A car is not just one entity but a culmination of many small parts. For example, a car consists of an engine, doors, wheels, windows, mirrors, seats, and so on and so forth. Similarly, web pages are made of a lot of tiny components called HTML elements.
Now, all HTML elements follow certain rules. Let me show you what is the syntax of these elements.
Let me dissect the above example.
Here is a commonly used HTML elements list to get you started.
Elements and tags in HTML are often used interchangeably, which can be very confusing. In this section of the tutorial, I will explain how elements are different from tags.
Point of difference | HTML elements | HTML tags |
Definition | An HTML element is the primary building block for a web page. | An HTML tag is a specific syntax for defining an HTML element. |
Composition | It typically includes an opening tag, content, and a closing tag. | It typically consists of the tag name enclosed in a pair of angle brackets. |
Examples | Include paragraphs (<p>), links (<a>), images (<img>), and divisions (<div>). | Include <p> to open paragraphs, </p> to close paragraphs, and <a> to open links, among others. |
Syntax | Self-closing (void) elements, like <br> for line breaks or <img> for images, do not require a closing tag. | Tags can be opened (<tagname>) to start an element or closed (</tagname>) to end it. |
There are a lot of HTML elements and tags in HTML coding. In this section of the tutorial, let me discuss some common HTML elements with examples.
Paragraphs and headings are basic HTML elements of text. We use <h1> to <h6> tags for headings, where <h1> is the largest font size and <h6> is the smallest. For paragraphs, we use the <p> tag. Let me show you an example program to explain the syntax.
Code:
|
In the above example, we have used all the heading sizes from <h1> to <h6>. Under each heading, we have incorporated a paragraph.
We can also incorporate lists into HTML. There are two types of lists in HTML: ordered and unordered lists. Let me show you an example program to explain the concept better.
Code:
|
In the above example, the <ul> tag creates an unordered list containing bullet points.
The <ol> creates an ordered list with sequentially numbered items. Each list item in <ul> or <ol> has its own individual <li> tag for each item.
We can also add tables to our website using HTML. Let me show you how with an example.
Code:
|
In the above example,
I have styled the table using inline CSS, which I have included in the <head> section. CSS styles are used to control the appearance of the table, headers, and cells (such as width, borders, padding, alignment, and background color).
The <style> section includes CSS rules for styling different elements in the document. Let me share an example.
Code:
|
In the above example, we have the style element in the head of the program to include all the CSS attributes.
A nested HTML element is when one element is inserted within another, resulting in a hierarchical structure in the HTML document. This allows you to code efficiently and helps with organizing content.
Let me share a small example to explain.
<div>
<p> This is a nested element </p>
</div>
In the above example, the paragraph is a nested element because it exists inside the <div> element, which can be called the parent element.
HTML elements serve as the foundation for web pages, allowing developers to structure and convey material properly. They are the building blocks of every website, no matter how complex. This tutorial has hopefully taught you the basics of elements in HTML, although there is always something new to learn as technology progresses, just like HTML5 introduced new HTML elements.
If you want to learn more complex concepts of HTML, you should definitely check out upGrad. Their courses are in collaboration with some of the best universities around the world. The courses are curated by some of the best professors in this field. Doing these certified courses is sure to add value to your skills.
The <html> element in HTML represents a webpage's main or root element. It includes all other HTML components, such as the <head> and <body>. The <html> element defines a webpage's structure and content and is the starting point for building HTML documents.
Elements in HTML are composed of opening and closing tags, with material inserted between them. Opening tags begin with < and end with >, whereas closing tags begin with </ and conclude with >. There are, however, self-closing tags like <img>, which do not need a closing tag.
Some common HTML elements are
Elements may include attributes. Attributes include additional information about an element and can be used to change its behavior, appearance, or usefulness.
HTML element names are not case-sensitive. This means that HTML element names can be written in capitals, lowercase, or a combination of the two, and web browsers will identify and interpret them correctly.
HTML elements can be nested inside one another. Nesting is the process of inserting one HTML element inside another.
The newest HTML5 specification includes 115 standard elements in HTML. These elements provide various functionalities, including text formatting, multimedia embedding, form controls, semantic organization, and more.
Empty elements do exist in HTML. They are those with no content or text between the opening and closing tags. These tags are self-closing and take the form <tagname> without a closing tag.
Mukesh Kumar
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...