HTML, which stands for Hypertext Markup Language, is the standard language used to create web pages. It is a markup language that uses tags to define the structure and content of a web page. In this post, we will go over the basics of HTML and how it works.
HTML Tags
As mentioned earlier, HTML uses tags to define the structure and content of a web page. A tag is a set of characters enclosed in angle brackets, such as <html>, <head>, and <body>. Each tag serves a specific purpose in defining the web page's structure and content.
Here are some commonly used HTML tags:
<html>
: This is the root element of an HTML document. It
contains all other elements of the page.
<head>
: This element contains the metadata of the web page,
such as the title, author, and description.
<title>
: This element defines the title of the web page,
which appears in the browser's title bar.
<body>
: This is the main content of the web page, such as
text, images, and videos.
<h1>
- <h6>
: These elements are used to
define headings of different sizes. <h1>
is the largest,
and <h6>
is the smallest.
<p>
: This element defines a paragraph of text.
<a>
: This element defines a hyperlink to another web page
or a specific section of the same page.
<img>
: This element defines an image in the web page.
HTML Attributes
HTML tags can also have attributes, which provide additional information about
the element. Attributes are specified in the opening tag of an element, such
as <img src="image.jpg">
. Here are some commonly used HTML
attributes:
id
: This attribute specifies a unique identifier for an element.
class
: This attribute specifies one or more classes for an
element, which can be used for styling with CSS.
src
: This attribute specifies the URL of an image or other
external resource.
href
: This attribute specifies the URL of a hyperlink.
HTML Document Structure
An HTML document has a specific structure that consists of the following elements:
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>Heading</h1> <p>Paragraph</p> </body> </html>
<!DOCTYPE html>
: This declaration specifies the document
type and version of HTML used in the document.
<html>
: This element is the root element of the document.
<head>
: This element contains the metadata of the document.
<title>
: This element specifies the title of the document.
<body>
: This element contains the main content of the
document.
Conclusion
HTML is the foundation of every web page on the internet. By learning the basics of HTML, you can create your own web pages and have a better understanding of how web pages work. This post covered some of the most commonly used HTML tags and attributes, as well as the structure of an HTML document. I hope you found this post helpful in getting started with HTML!