What is HTML?


What it is?
HTML (HyperText Markup Language) is a markup language that tells web browsers how to structure the web pages you visit. It can be as complicated or as simple as the web developer wants it to be.
HTML consists of a series of elements, used to enclose, wrap, or mark up different parts of content to make it appear or act in a certain way. The enclosing tags can make content into a hyperlink to connect to another page, italicize words, and so on.
HTML lives inside text files called HTML documents, or just documents, with a .html
file extension. Where previously we've talked about web pages, an HTML document contains the web page's content and specifies its structure.
The most common HTML file you'll encounter is index.html
, which is generally used to contain a website's home page content. It's also common to see subfolders with their own index.html
, so a website can have multiple index files in different places.
Anatomy of an HTML element
The anatomy of element is:
The opening tag: This consists of the name of the element (in this example, p for paragraph), wrapped in opening and closing angle brackets. This opening tag marks where the element begins or starts to take effect. In this example, it precedes the start of the paragraph text.
The content: This is the content of the element. In this example, it is the paragraph text.
The closing tag: This is the same as the opening tag, except that it includes a forward slash before the element name. This marks where the element ends. Failing to include a closing tag is a common beginner error that can produce peculiar results.
Void Elements
Not all elements follow the pattern of an opening tag, content, and a closing tag. Some elements consist of a single tag, which is typically used to insert/embed something in the document. Such elements are called void elements.
For example, the <img> element is one of the void element.
<img
src="https://raw.githubusercontent.com/mdn/beginner-html-site/gh-pages/images/firefox-icon.png"
alt="Firefox icon"
/>
Attributes
Elements can also have attributes. Attributes look like this:
Attributes contain extra information about the element that won't appear in the content. In this example, the class
attribute is an identifying name used to target the element with style information.
An attribute should have:
A space between it and the element name. (For an element with more than one attribute, the attributes should be separated by spaces too.)
The attribute name, followed by an equal sign.
An attribute value, wrapped with opening and closing quote marks.
Boolean Attributes
Sometimes you will see attributes written without values. This is entirely acceptable. These are called Boolean Attributes. When a Boolean Attribute is written without a value, or with any value, even like "false"
, the boolean attribute is always set to true. Otherwise, if the attribute is not written in an HTML tag, the attribute is set to false.
Example of a Boolean Attribute:
<input type="text" disabled="disabled" />
Conclusion
This summarizes the introduction to HTML. Elements are the building blocks of an HTML document.
Subscribe to my newsletter
Read articles from Subodh Awate directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
