Está en la página 1de 3

Some Basic HTML Tags

Line Break Tag


Whenever you use the <br> element, anything following it starts from the next line. This tag is an
example of an empty element tag, where you do not need opening and closing tags.
Syntax- Line 1<br>Line 2

Centering Content
You can use <center> tag to put any content in the center of the page or any table cell.
Syntax- <center><p>This text is centered</p></center>

Horizontal Lines
Horizontal lines or Horizontal Rulers are used to visually break up sections of a document. The <hr> tag
creates a line from the current position in the document to the right margin and breaks the line
accordingly. It is an empty element tag.

Preserve Formatting
Sometimes you want your text to follow the exact format of how it is written in the HTML document. In
those cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve the formatting of the
source document.
Syntax- <pre> This Para shows use of pre tag.
No tag is required to break line
</pre>

Hyper Linking
To create a link in HTML, we use an anchor tag <a>. The Reference is given using the reference
attribute i.e. href. The address is given double quotes.
Syntax- <a href=address, for example C:/Users/Documents/123.html>Go to 123 page</a>

HTML Images

HTML images are defined with the <img> tag.


The source file (src), alternative text (alt), and size (width and height) are provided as attributes:

Syntax- <img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">

Download Link
You can provide a download link by typing the attribute download after the address of the file in a
normal link.
Syntax- <a href=address, for example C:/Users/Documents/myimage.png download>Download My
Photo </a>

Font Tag
To change font type, we can use <font> tag. It has 3 attributes: face, color (not colour) and size. Face
defines the font type (such as Arial, Comic Sans MS etc). Color defines the font color (such as red,
green, cyan etc). Size defines the font size. Font size varies from 1 to 7.
Syntax- <p><font face=Comic Sans MS color=cyan size=4>This is text</font></p>

Font Style Tags


We can use bold, italic and underline as tags also in the form of <b>, <i> and <u>.
Syntax- <p>My Name is<b>Ronald Weasley</b>. I am the best friend of <u>Harry Potter</u> and
<i>Hermione Granger</i> is my<b>girlfriend</b>.

Alignment Tags
There are 4 types of alignments left, right, center and justify. It can be used as an attribute of <p> and
<h1> tags.

Syntax- <h3 align=center>This heading is center aligned</h3>

Subscript and Superscript

These tags can be defined as <sub> and <sup>.


Example for displaying the chemical name of water
<p>The Chemical name of water is H<sub>2</sub>O</p>
Example for displaying the square of A
<p>The square of A is A<sub>2</sub></p>

Setting Background Colour


The background color of a webpage can be changed using bgcolor attribute of <body> tag.
Syntax- <body bgcolor=red>

Setting Background Image


The background image of a webpage can be set using background attribute of <body> tag.
Syntax- <body background=address of the image>

Changing Font Style


While the font tag changes the font styling of only a specific part of webpage, the text attribute of <body>
tag changes the font style of the entire webpage.
Syntax- <body text=Comic Sans MS>

Marquee
Displays a moving text on the background. It has many attributes, like width (in %), height (in pixelsnumbers), bgcolor (specifies colour) and behavior (How the text moves, has 3 values, Alternate, Scroll
and Slide).
Syntax- <marquee width=100% height=30 behavior=alternate bgcolor=blue>My Site</marquee>