Q. What Are HTML Tags?
Ans: -It is a markup language and makes use of various tags to format the content. HTML Tags are the building blocks of Hypertext markup language. They are used to define the Hypertext markup language elements that should appear on a web page. Without tags, you wouldn’t have an Hyper text markup language page. These tags are enclosed within angle braces <Tag Name>. Except few tags, most of the tags have their corresponding closing tags. For example <body> tag has its closing tag </body> tag etc.
Tags can be of two types. They are
1) Paired Tags: – A tag is said to be a paired tag if the text is placed between a tag and its companion tag. In paired tags, the
first tag is referred to as Opening Tag and the second tag is referred to as Closing Tag.
Ex: – <p> text </p>
2) Unpaired tags: – unpaired tags are those tags which don’t have a closing tag.
Ex: – <BR />
HTML document uses following HTML Tags:
|<!DOCTYPE…>||This tag defines the document type and HTML version|
|<HTML>||This tag encloses the complete HTML document and mainly comprises of document header which is
represented by <head>…</head> and document body which is represented by <body>…</body> tags.
|<Head>||This tag represents the document’s header which can keep other HTML tags like <title>, <link> etc.|
|<Title>||The <title> tag is used inside the <head> tag to mention the document title|
|<Body>||This tag represents the document’s body which keeps other HTML tags like <h1>, <div>, <p> etc.|
👉🏽HTML Elements: –HTML documents are made up by HTML elements. HTML elements are written with a start tag, with an end tag, with the content in between: <tagname>content</tagname> content The HTML element is everything from the start tag to the end tag:
<p> My first HTML paragraph. </p>
👉🏽HTML Attributes:- – Attributes provide additional information about HTML elements. HTML elements can have attributes.
- Attributes provide additional information about an element.
- Attributes are always specified in the start tag
- Attributes come in name/value pairs like: name=”value”.
- Ex: – <body text=”Red”>
Basic Basic Tags
👉🏽<Body> Tags: –The <body> tag defines the document’s body. The <body> element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc
Attributes of <Body> tags:
|Text||Color||Specifies the color of the text in a document|
|Background||Url||Specifies a background image|
|BgColor||Color||Specifies the background color of a document|
|Leftmargin||number||Sets a left hand margin for your body element|
|Topmargin||number||Sets a margin along the top of your body element|
|Link||Color||Specifies the color of unvisited links in a document|
|Vlink||Color||Specifies the color of visited links in a document|
|Alink||Color||Specifies the color of an active link in a document|
<!DOCTYPE html> <html> <head> <title>Body Attributes</title> </head> <body text=red bgcolor=Yellow topmargin=20 leftmargin=40> My job portal web sarkariflix.com </body> </html>
Screenshot of above html document in Notepad++
Below screenshot of above document run in chrome browser
This article is written by:- Vivekanand