Basic Tags and Attributes in HTML


What is an Attribute?


Body tag and its attributes

Background attribute

This attribute is used to specify the backgroung image of the HTML page.

For Example: <body background ="background_image.jpg" >

Background Image attribute-Body tag
Bgcolor attribute

This attribute is used to specify the backgroung color of the HTML page.

For Example: <body bgcolor ="blue" >

Background Color attribute-Body tag
Text attribute

This attribute is used to specify the color of text of the entire HTML page.

For Example: <body text ="red" >

Text Color attribute-Body tag

Heading Tags

Heading Tags are used to define the different heading levels in an HTML document.

There are 6 Heading tags: H1 to H6, H1 displaying text in the largest size and H6 in the smallest size.

Heading Tags are usually used for main headings and sub heading.

Heading Tags in HTML
Align attribute

This attribute is used to align Headings in an HTML document.

The align attribute has 4 values:

<h1 align ="center" > - Aligns the text in the center.
<h1 align ="right" > - Aligns the text to the right side.
<h1 align ="wrong" > - Aligns the text to the left side.
<h1 align ="justify" > - Aligns the text from both left and right margins.

Align Attribute

Paragraph Tag

Paragraph tags are used to display a block of text as a paragraph in an HTML document.

Every paragraph begins from a new line.

When you start a new paragraph, the web browsers will leave some space between the paragraphs.

The Align attribute can also be given with <p> tags, <hr> tags, <span> tags, heading tags, etc.

Paragraph Tag in HTML

<hr> Tag

<hr> tags are used as a separator between blocks of text in an HTML document.

The <hr> tag draws a horizontal line across the page.

The size attribute of <hr> tag is given in pixels.

The attributes of <hr> tag include are:

Size : Specifies the thickness of the horizontal rule. <hr size ="4">

Width : Specifies the length of the horizontal rule. <hr width ="80%">

Align : Specifies the alignment of the horizontal rule. The possible values for align attribute include right, left and center. <hr align ="center">

Color : Specifies the color of the horizontal rule. <hr color ="red">

Noshade : This attribute produces a solid block horizontal rule with no shading. <hr noshade >

hr tag and its attributes

Center Tag

The <center> tag is used to align the text to the center of the page.
The contents between the opening and closing <center> tag will be centered in the display window.

Center tag in HTML

Comments in HTML

Sometimes you might want to write notes for yourself in an HTML document, but don't want this to appear in the browser window.

This is where the Comment tag comes in.

<!-- This is how a comment is written -->

Note that only the opening tag of a comment has an exclamation mark(!).


For Example:

<html>
<head>
<title>Example | Kode.Blox </title>
</head>
<body bgcolor ="black" text ="white" >
<!-- This example will help you understand how attributes and comments work in HTML. -->
<center> <h1> Today's Motivation! </h1> </center>
<hr size ="2" width ="90%" color ="yellow" >
<p>
“Knowing Is Not Enough; We Must Apply. Wishing Is Not Enough; We Must Do.”
</p>
<p align ="right" > Johann Wolfgang Von Goethe </p>
<hr size ="4" width ="80%" noshade >
</body>
</html>


Prev

Next