HTML Syntax
HTML or Hypertext Markup Language is the basic building block of the web that is used to create web pages and web applications.
It is the backbone of any website. It is essential for the proper functioning of web pages.
An HTML document is a text file that generally contains the following things. They are:
- The text of the page itself
- HTML markup tags that tell the browser how to display the web page. It identifies page elements, structure, formatting, media, and hypertext links to other pages. An HTML tag surrounds the text and applies meaning to it. We write it between angle brackets < and >.
- Attributes that provide extra information about the element, and we applied it within the start tag. An HTML attribute comprises two fields: name and value.
Basic HTML Syntax
A basic HTML syntax refers to a set of rules that regulate the structure, elements, and attributes of HTML code. The general syntax of HTML is as follows:
<tagname>content</tagname>
In the above syntax, the tag name (here, tagname) itself is enclosed in angle brackets (<>). HTML tags contain an opening and a closing tag surrounding the content they affect.
The opening tag “turns on” a feature (like heading, paragraph, bold, etc.) and the closing tag turns it off. A forward slash (/) indicates a closing tag in the above syntax. HTML tags define the structure and meaning of web content.
Let’s take some examples based on this HTML syntax.
1. <h1>Heading</h1>
2. <h2>Heading</h2>
3. <p>Paragraph</p>
Basic Syntax with Attribute
The general HTML syntax with an attribute is as:
<tagname attribute_name= " attribute_value">content</ tagname>
In the above syntax, an attribute provides additional information about the markup tags. It is usually defined as attribute_name = attribute_value pairs that follow the tag name separated by a white space.
Let’s take some examples based on this HTML syntax.
Example:
1. <h1 id = "topHeading">Understanding basic HTML syntax: A Comprehensive Guide</h1>
2. <a href = "http://www.google.com/" > Click here to visit Google’s Website.< /a >
In this tutorial, you have known about the basic HTML syntax with the help of examples. I hope that you will have understood the basic syntax. Stay tuned with the next tutorial where you will learn HTML elements.
Thanks for reading!!!