NEW

6/recent/ticker-posts

Header Ads Widget

HTML & HTML 5 Tags

 

HTML 5 Tags

There is a list of newly included tags in HTML 5. These HTML 5 tags (elements) provide a better document structure. This list shows all HTML 5 tags in alphabetical order with description.

List of HTML 5 Tags

TagDescription
<article>This element is used to define an independent piece of content in a document, that may be a blog, a magazine or a newspaper article.
<aside>It specifies that article is slightly related to the rest of the whole page.
<audio>It is used to play audio file in HTML.
<bdi>The bdi stands for bi-directional isolation. It isolates a part of text that is formatted in other direction from the outside text document.
<canvas>It is used to draw canvas.
<data>It provides machine readable version of its data.
<datalist>It provides auto complete feature for textfield.
<details>It specifies the additional information or controls required by user.
<dialog>It defines a window or a dialog box.
<figcaption>It is used to define a caption for a <figure> element.
<figure>It defines a self-contained content like photos, diagrams etc.
<footer>It defines a footer for a section.
<header>It defines a header for a section.
<main>It defines the main content of a document.
<mark>It specifies the marked or highlighted content.
<menuitem>It defines a command that the user can invoke from a popup menu.
<meter>It is used to measure the scalar value within a given range.
<nav>It is used to define the navigation link in the document.
<progress>It specifies the progress of the task.
<rp>It defines what to show in browser that don't support ruby annotation.
<rt>It defines an explanation/pronunciation of characters.
<ruby>It defines ruby annotation along with <rp> and <rt>.
<section>It defines a section in the document.
<summary>It specifies a visible heading for <detailed> element.
<svg>It is used to display shapes.
<time>It is used to define a date/time.
<video>It is used to play video file in HTML.
<wbr>It defines a possible line break.


HTML <!DOCTYPE> tag

On the HTML document you have often seen that there is a <!DOCTYPE html> declaration before the <html> tag. HTML <!DOCTYPE> tag is used to inform the browser about the version of HTML used in the document. It is called as the document type declaration (DTD).

Technically <!DOCTYPE > is not a tag/element, it just an instruction to the browser about the document type. It is a null element which does not contain the closing tag, and must not include any content within it.

Actually, there are many type of HTML e.g. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc.

The <!DOCTYPE> declaration refers Document Type Declaration (DTD) in HTML 4.01; because HTML 4.01 was based on SGML. But HTML 5 is not SGML based language.

DTD defines the rules for the markup languages so that the browsers recognize the content correctly.

The doctype declaration differs between HTML versions. The HTML 5 doctype declaration is given below.

Syntax

<!DOCTYPE html>

Following are some specifications about the HTML <!DOCTYPE>

DisplayNone
Start tag/End tagStart tag only
UsageStructural

Let's see an example of HTML document with doctype declaration.

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <title>This is the title</title>  
  5. </head>  
  6. <body>  
  7. This is the content of the document.  
  8. </body>  
  9. </html>  



HTML Anchor

The HTML anchor tag defines a hyperlink that links one page to another page. It can create hyperlink to other web page as well as files, location, or any URL. The "href" attribute is the most important attribute of the HTML a tag. and which links to destination page or URL.

href attribute of HTML anchor tag

The href attribute is used to define the address of the file to be linked. In other words, it points out the destination page.

The syntax of HTML anchor tag is given below.

<a href = "..........."> Link Text </a>

Let's see an example of HTML anchor tag.

<a href="second.html">Click for Second Page</a>  



Specify a location for Link using target attribute

If we want to open that link to another page then we can use target attribute of <a> tag. With the help of this link will be open in next page.

Example:

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title></title>  
  5. </head>  
  6. <body>  
  7. <p>Click on <a href="https://www.slogantechblog.com/" target="_blank"> this-link </a>to go on home page of JavaTpoint.</p>  
  8. </body>  
  9. </html>  

Output:

HTML Anchor

Note:

  • The target attribute can only use with href attribute in anchor tag.
  • If we will not use target attribute then link will open in same page.

Appearance of HTML anchor tag

An unvisited link is displayed underlined and blue.

visited link displayed underlined and purple.

An active link is underlined and red.


HTML <abbr> tag

HTML <abbr> tag is used to represent an acronym or abbreviation of a longer word or phrase, such as www, HTML, HTTP, etc. The content written between <abbr> tags renders with dotted underline in some browser.

This tag can be used with "title" attribute (optional), and the value of title attribute will be pop-up when the mouse hovers over the content written between <abbr> tag.

Syntax

  1. <abbr title="HyperText Markup language">HTML</abbr>  

Following are some specifications about the HTML <abbr> tag

DisplayInline
Start tag/End tagBoth Start tag and End tag
UsageSemantic/Textual

Example

With title Attribute:

 

  1. <!DOCTYPE html> 
  2. <html>  
  3.   <head>  
  4.     <title>Abbreviation Tag</title>  
  5.    </head>  
  6.  <body>  
  7.     <h2>Abbreviation tag example</h2>  
  8.     <p><b>Hover mouse over the content and see the abbreviation</b></p>  
  9.                <abbr title="Hyper Text Transfer protocol">HTTP</abbr>  
  10.     </body>  
  11. </html>   


Example

Without title Attribute:

  1. <!DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.     <title>Abbreviation tag</title>  
  5.  </head>  
  6.   <body>  
  7.    <h2>Abbreviation tag Example</h2>  
  8.    <p><abbr>CPU</abbr> is brain of a Computer</p>  
  9.   </body>  
  10. </html>  


Global attributes:

The <abbr> tag supports the global attributes.

Event Attributes:

The <abbr> tag supports the event attributes.


HTML <acronym> tag (Not supported in HTML5)

HTML <acronym> tag is used with title attribute to contain a full explanation of an acronym content. When you hover the mouse on content, then it will show the explanation of word.

Note: The <acronym> tag has been depreciated in HTML5 and we can use <abbr> tag instead of <acronym>.

Syntax

  1. <acronym title="Indian Space Research Organisation">ISRO</acronym>  

Following are some specifications about the HTML <acronym> tag

DisplayInline
Start tag/End tagBoth Start tag and End tag
UsageSemantic/Textual

Example

  1. <!DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.     <title>Acronym tag</title>  
  5.  </head>  
  6.   <body>  
  7.    <h2>Acronym tag Example</h2>  
  8.    <acronym title="Indian Space Research Organisation">ISRO</acronym>  
  9.   </body>  
  10. </html>  


Difference between <acronym> and <abbr> tag

Although <acronym> tag is not supported by HTML5 but instead of that we can use <abbr> tag and we will get the same result using both tag.

Example

  1. <!DOCTYPE html>  
  2.  <html>  
  3.   <head>  
  4.    </head>  
  5.   <body>  
  6.    <h2>Acronym and Abbreviation Example</h2>  
  7.    <acronym title="Indian Space Research Organisation">ISRO</acronym>  
  8.    <abbr title="National Aeronautics and Space Administration">NASA</abbr>  
  9.   </body>  
  10. </html>  


HTML <address> tag

HTML <address> tag is used to specify the authorship information of the article or webpage. It can contain any type of information which is needed such as, URL, physical address, phone number, email, other links, etc.

The <address> tag is useful for various contexts such as business contact information in the header of the page, or author related contact information, etc.

The contact information written between <address> tags mostly renders in the italic form on the browser.

Note: To represent a random address use <p> tag instead of <address> tag, as it should contain the main contact information.

Syntax

  1. <address>Contact Author at:<br>  
  2. <a href="mailto:example@gmail.com">Example@gmail.com</a></address>  

If you want to specify the information of the author for an article, you must place the <address> tag inside the <article> element.

Following are the specifications of <address> tag:

DisplayBlock
UsageSemantic
TagsStart and end tag

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Address Tag</title>  
  5. </head>  
  6. <body>  
  7.     <h2>Example of Address tag</h2>  
  8.                 <address>The article is written by:<b>Harshita</b> <br>Contact Author at:  
  9.         <a href="mailto:example@gmail.com">Example@gmail.com</a><br>You can also visit      our blog:  
  10.        <a href="http://slogantechblog.blogspot.com/">javaTpoint blog</a>  
  11.                 </address>  
  12.   </body>  
  13. </html>  

Attributes

The <address> tag does not contain any specific attribute for it.

Global Attribute:

The <address> tag supports the global attributes.

Event attribute:

The <address> tag supports all Events attributes.


HTML <applet> tag (Not supported in HTML5)

HTML <applet> tag was used to embed the Java applet in an HTML document. This element has been deprecated in HTML 4.0 and instead of it we can use <object> and newly added element <embed>.

The use of Java applet is also deprecated, and most browsers do not support the use of plugins.

Note: The <applet> tag is deprecated in HTML4.0 and not supported in HTML5. So you can use <object> tag or <embed> tag instead of <applet>.

Syntax

  1. <applet code="URL" height="200" width="100">.............</applet>  

Following are some specifications about <applet> tag

DisplayBlock
Start tag/End tagBoth Start tag and End tag
UsageEmbed Applets

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.   <title>Applet Tag</title>  
  5.  </head>  
  6.  <body>  
  7.    <p>Example of Applet Tag</p>  
  8.     <applet code="Shapes.class" align="right" height="200" width="300">  
  9.      <b>Sorry! you need Java to see this</b>  
  10.      </applet>  
  11.   </body>  
  12. </html>  


Attributes

Specific Attributes

Attribute nameValueDescription
codeURLIt specifies the URL of Java applet class file.
widthpixelsIt specifies the display width of the applet panel.
heightpixelsIt specifies the display height of applet panel
align
  • left
  • right
  • top
  • middle
  • bottom
It specifies the position of applet application relative to surrounding content.
alttextIt is used to display alternative text in case browser does not support Java.
archiveURLThis specifies the archived or compressed version of an applet application.
objectnameIt specifies the URL or reference to a serialized representation of an applet.
codebaseURLIt specifies the exact or relative URL of applets .class file specified in the code attribute.
hspacepixelsIt specifies the horizontal space around the applet.
vspacepixelsIt specifies the vertical space around the applet.
namenameIt specifies the name for the applet

Global Attributes

The <applet> tag supports all Global Attributes in HTML

Event Attributes

The <applet> tag supports all Event Attributes in HTML


HTML <area> tag

Description:

The <area> tag defines the clickable areas or active areas inside the image-map which are associated with the hyperlinks. If you click on those areas then it will perform some action such as open a new image, new URL, etc. This tag is always used with <map> element.

Inside an image map different areas can be hyperlinked to various locations using multiple <area> elements in a single <map> element.

The <area> element is defined with (required) attributes shape and coords. The shape attribute specifies the shape of the area such as rectanglecirclesquare, and polygon. The coords attribute defines the coordinates of areas inside the image.

What is Image-map

An image-map is defined as a graphical image with active areas so that when user click on those area, it can link to different destinations. To define an image-map, we require the following things:

An HTML <img> element with usemap attribute which defines a valid map name.

  • HTML <map> element with name attribute whose value must be same as usemap
  • One or more <area> elements inside a <map> element which create clickable areas in an image-map.

Syntax

  1. <area shape="" coords="" href="">  

Following are some specifications about the HTML <area> tag

DisplayBlock
Start tag/End tagOnly start tag(End tag forbidden)
UsageImage Map

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3.  <head>  
  4. <title>HTML Area tag</title>  
  5. <style>  
  6.   body{  
  7.   margin-left: 250px;}  
  8. </style>  
  9.   </head>  
  10.  <body>  
  11.  <h2>Example of HTML Area tag</h2>  
  12. <img src="image1.png" usemap="#web">  
  13. <map name="web">  
  14. <area shape="rect" coords="66,117,131,168" href="https://www.slogantechblog.com/html-tutorial">  
  15. <area shape="rect" coords="199,36,277,85" href="https://www.slogantechblog.com/css-tutorial">  
  16. <area shape="rect" coords="330,107,406,159" href="https://www.slogantechblog.com/bootstrap-tutorial">  
  17. <area shape="rect" coords="199,185,267,236" href="https://www.slogantechblog.com/javascript-tutorial">  
  18.  </map>  
  19.  </body>  
  20. </html>  


HTML area tag

Attribute:

Tag-specific attributes:

AttributeValueDescription
alttextAn alternative text String to display on the browser if it does not display the image.
coordsx1,y1,x2,y2(rect)Defines coordinates for the upper left and lower right of a rectangle.
x,y, radius(circle)Defines coordinates for the circle.
x1,y1,x2,y2,x3,y3,..(polygon)Defines the polygon vertices.
hrefhrefURL It determines the hyperlink destination for the active area.
target_blankOpen link in a new window
_parentOpen link in the parent frame
_selfOpen link in current window
_topOpen link with full width in the same window
frame_nameIn the frame. (Not supported in HTML5)
shapedefaultIt defines the default area(rectangular).
rectIt defines the rectangular area.
circleDefines the circular area.
polyDefines the polygonal.
downloadfilenameDefines that hyperlink, which is used for downloading the resource.
relHTML Tags Listalternate
author
bookmark
help
license
next
nofollow
noreferrer
prefetch
prev
search
tag
It defines the relationship between current and linked document.
hreflangHTML Tags Listlanguage_codeIt specifies the language of the linked resource.
typeHTML Tags Listmedia_typeIt specifies the MIME type of linked source.(Not supported in HTML5)

Global attribute:

The <area> tag supports the global attributes in HTML

Event attribute:

The <area> tag supports the event attributes in HTML.


HTML Article Tag

The HTML <article> tag defines an independent self-contained content in a document, page, application or a site.

The article tag content makes sense on its own. It is independent and complete from other content shown on the page. This tag is generally used on Forum post, Blog post, News story, comment etc.


HTML article tag example

  1. <article>  
  2.  <h2>Narendra Modi</h2>  
  3.   <i>(Naam to suna hi hoga) </i>  
  4.   <p>Narendra DamodarDas Modi is the 15th and current Prime Minister of India,    
  5.   Modi, a leader of the Bharatiya Janata Party (BJP), previously served as the Chief Minister  
  6.   of Gujarat state from 2001 to 2014. He is currently the Member of Parliament (MP) from Varanasi. </p>  
  7. </article>  


Output:

Narendra Modi

(Naam to suna hi hoga)

Narendra DamodarDas Modi is the 15th and current Prime Minister of India, Modi, a leader of the Bharatiya Janata Party (BJP), previously served as the Chief Minister of Gujarat state from 2001 to 2014. He is currently the Member of Parliament (MP) from Varanasi.


HTML article tag also supports global and event attributes in HTML.



HTML Aside Tag

The HTML <aside> tag provides information about the main content. According to W3C definition, the <aside> element represents content that forms the main textual flow of a document.

HTML aside is a new tag introduced in HTML5.


HTML aside tag example

  1. <p>I don't want to live in Ghaziabad, I wish; I could buy a flat in New Delhi.</p>  
  2. <aside>  
  3.   <h3>New Delhi</h3>  
  4.   <p>New Delhi is the capital of India.</p>  
  5. </aside>  


Output:

I don't want to live in Ghaziabad, I wish; I could buy a flat in New Delhi.


HTML aside tag also supports global and event attributes in HTML.


HTML Audio Tag

HTML audio tag is used to define sounds such as music and other audio clips. Currently there are three supported file format for HTML 5 audio tag.

  1. mp3
  2. wav
  3. ogg

HTML5 supports <video> and <audio> controls. The Flash, Silverlight and similar technologies are used to play the multimedia items.

This table defines that which web browser supports which audio file format.

Browsermp3wavogg
ie browser Internet Exploreryesnono
chrome browser Google Chromeyesyesyes
firefox browser Mozilla Firefoxyes*yesyes
opera browser Operanoyesyes
safari browser Apple Safariyesyesno

HTML Audio Tag Example

Let's see the code to play mp3 file using HTML audio tag.

  1. <audio controls>  
  2.   <source src="koyal.mp3" type="audio/mpeg">  
  3. Your browser does not support the html audio tag.  
  4. </audio>  


Output:

Let's see the example to play ogg file using HTML audio tag.

  1. <audio controls>  
  2.   <source src="koyal.ogg" type="audio/ogg">  
  3. Your browser does not support the html audio tag.  
  4. </audio>  




HTML bold tag

HTML bold tag is represented by <b> tag.

HTML <b> tag is used to display the written text in bold format. It is strictly a presentational element. If you want to show your text in bold letters and not have real semantic meaning, then put it within <b>.......</b> tag.


Difference between HTML <b> and <strong> tag

The b tag is explicit whereas strong tag is semantic.The <strong> tag adds extra semantic meaning to the HTML document.

It is recommended to use strong tag for bold format now.

HTML bold tag example

  1. <p> Hello guys, <b>this is the method to write bold text.</b></p>  

Output:

Hello guys, this is the method to write bold text.


Note: According to HTML5 specification, b tag should be used only if no other tag is appropriate. For example: If you want to write a heading, you must use the header tag <h1> to <h6>. Important statement should be denoted within <strong>.....</strong> tag, and the text you want to mark or highlight, must be put within <mark>...</mark> tag.

There is also a CSS 'font-weight' property to set bold text.

HTML <base> tag

HTML <base> tag is used to specify a base URI or URL to use for all relative links contained within an HTML document.

Only one <base> element can be specified within a document, and it must be placed within <head> element. We can also specify how other links should open (in the same window, in another window, etc.) using the target attribute.

Syntax

  1. <base href="https://www.slogantechblog.com">  

In HTML <base> element does not contain closing tag but in XHTML end tag </base> is required.

Following are some specifications about the <base> tag

DisplayNone
Start tag/End tagOnly start-tag
UsageAnchors and links

Example

Open in same window (by default)

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Base tag</title>  
  5.     <style>  
  6.       a{text-decoration: none;  
  7.         color:black;}  
  8.       a:hover{color: green;  
  9.                    font-size: 18px;}  
  10.     </style>  
  11.     <base href="https://wwwslogantechblog.com">  
  12.  </head>  
  13.  <body>  
  14.         <h2 style="color: red; font-size: 30px; font-style: italic;">List of Web developement Tutorial</h2>  
  15.         <a href="/html-tutorial">HTML tutorial</a><br>  
  16.         <a href="/css-tutorial">CSS tutorial</a><br>  
  17.         <a href="/bootstrap-tutorial">Bootstrap tutorial</a><br>  
  18.         <a href="/javascript-tutorial">JavaScript tutorial</a><br>  
  19.     <a href="/jquery-tutorial">JavaScript tutorial</a>  
  20.   </body>  
  21. </html>  

In the above example we have used base URL =" https://www.javatpoint.com" which all other relative links will treat as starting URL. Here (/) defines the root URL of the current document.

Open in new window (using _blank in <base> tag):

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Base tag</title>  
  5.     <style>  
  6.       a{text-decoration: none;  
  7.         color:black;}  
  8.       a:hover{color: green;  
  9.             font-size: 18px;}  
  10.     </style>  
  11.     <base href="https://www.slogantechblog.com" target="_blank">  
  12.  </head>  
  13.  <body>  
  14.         <h2 style="color: red; font-size: 30px; font-style: italic;">List of Web developement Tutorial</h2>  
  15.         <a href="/html-tutorial">HTML tutorial</a><br>  
  16.         <a href="/css-tutorial">CSS tutorial</a><br>  
  17.         <a href="/bootstrap-tutorial">Bootstrap tutorial</a><br>  
  18.         <a href="/javascript-tutorial">JavaScript tutorial</a><br>  
  19.         <a href="/jquery-tutorial">JavaScript tutorial</a>  
  20.   </body>  
  21. </html>  

In the above example we have used target="_blank" in only <base> tag but it is applied on whole document links.

Attribute

Tag Specific attributes:

AttributeValueDefinition
hrefURLIt specifies the base URL for all relative links.
target
_blankOpen the relative link in the new window
_selfOpen the relative link in current window
_parentOpen the relative link in the parent frame
_topOpen the links in full width of the page

Global Attribute

The <base> tag supports all global attributes in HTML

Event Attribute

The <base> does not support the event attributes in HTML


HTML <basefont> tag

(Not Supported in HTML5)

HTML <basefont> tag was used to specify the default value of font-size, color, and font-family for all content written within an HTML document.

Note: The <basefont> was deprecated in HTML 4 and completely removed from HTML5 so do not use this tag, instead of it you can use CSS to style the document.

Syntax

  1. <basefont color="blue" size="5" face="arial">  

In HTML the closing tag </basefont> is not required but in XHTML the end tag is required.

Following are some specifications about the <base> tag

DisplayNone (empty tag)
Start tag/End tagOnly start-tag
UsageFont styling

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <title>Basefont tag</title>  
  5.  <basefont color="blue" size="5" face="arial">  
  6. </head>  
  7. <body>   
  8. <h2>Example of Basefont tag</h2>  
  9. <p>The basefornt tag is not supported in HTML5 use CSS to style the document</p>  
  10. </body>  
  11. </html>  

Right way is to Use CSS to set the base font:

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.  <style>  
  5.     p{  
  6.         font-size: 20px;  
  7.          color: #67dfee;  
  8.         font-family: Helvetica;  
  9.                     }  
  10.  </style>  
  11. </head>  
  12. <body>  
  13. <h2>CSS to Style the document</h2>  
  14. <p>This is Paragraph</p>  
  15. </body>  
  16. </html>  

Attributes

Tag specific attributes:

AttributeValueDescription
colorcolorSpecify the default color of all text within an HTML document. (Not Supported in HTML5)
facefont-familySpecify the default font face for the text in the document. (Not Supported in HTML5)
sizenumberSpecify the size of the text. (Not Supported in HTML5)


HTML <bdi> tag

HTML <bdi> tag stands for Bidirectional Isolate Element. It is used to inform the browser to isolate the span of text which may be formatted in opposite directions than the surrounding text.

This tag is new in HTML5 and useful for languages such as Arabic or Hebrew, or if the browser dynamically inserts some text without knowing the directionality of text.

Note: The directionality of content inside <bdi> does not influence by the directionality of surrounding content.

Syntax

  1. <bdi>Content</bdi>  

Following are some specifications about the <bdi> tag

DisplayInline
Start tag/End tagBoth start and End tag
UsageSemantic/textual

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <title>Bdi tag</title>  
  5.              <style>  
  6.      bdi{  
  7.            font-size: 25px;  
  8.                      color: red; }  
  9.        </style>  
  10. </head>  
  11. <body>  
  12. <h2>Example of HTML bdi tag</h2>  
  13. <p>  
  14. This <bdi> ???? ????? </bdi>  Content is written in Arabic language  
  15. </p>  
  16. </body>  
  17. </html>  

Output:

HTML bdi tag

Attributes

Tag-specific attribute:

The <bdi> tag does not include any specific attribute

Global attribute:

The <bdi> tag supports all Global attribute

Event Attributes:

The <bdi> tag supports all Event Attributes

Difference between <bdi> and <bdo>

HTML <bdi> tag is new element of HTML5 and it is very similar to HTML <bdo> element. But the main difference in both the elements is that <bdi> tag isolates the content from its surrounding content but <bdo> tag reveres the direction. Sometimes <bdo> tag may cause some unexpected rendering errors so try to use <bdi> if required.

HTML <bdo> tag

HTML <bdo> tag stands for "bidirectional override" which is used to overrides the current/default text direction. This tag sets the direction of content within it to render on browser from left to right or right to left.

The <bdo> tag is useful for the languages which are written from right to left such as Arabic and Hebrew.

Syntax

  1. <bdo dir=" "> Content......</bdo>  

Following are some specifications about the <bdo> tag

DisplayInline
Start tag/End tagBoth start and End tag
Usagetextual

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Bdo tag</title>  
  5.  </head>  
  6. <body>  
  7.      <h2>Example of HTML bdo tag</h2>  
  8.      <p style="color:#ff4040">This is Normal Content with default directionality</p>  
  9.      <p>This is with left to right directionality:  
  10.          <bdo dir="ltr" style="color: #5f9ea0">A beautiful Flower</bdo>  
  11.      </p>  
  12.       <p>This is with right to left directionality:  
  13.          <bdo dir="rtl" style="color:#68228b">A beautiful Flower</bdo>  
  14.       </p>  
  15.  </body>  
  16. </html>  


Output:

HTML bdo tag

Attributes

Tag-specific attributes

AttributeValueDescription
dir
ltrDefines the directionality from left to right.
rtlDefines the directionality from right to left.

Global Attributes

The <bdo> tag supports the Global attribute in HTML.

Event Attributes

The <bdo> tag supports the Event attribute in HTML.

HTML <big> tag (Not supported in HTML5)

HTML <big> tag was used to increase the text font size one level bigger than the document's base font size or surrounding text size, such as small to medium, medium to large, etc.

NOTE: HTML <big> tag is no longer supported by HTML5, so you can use CSS to increase the font size.

Syntax

  1. <big>Content... </big>  

Following are some specifications about the <big> tag

DisplayInline
Start tag/End tagBoth start and End tag
UsageFonts and Web Typography

Example

  1.  <!DOCTYPE html>  
  2.  <html>  
  3.  <head>  
  4.    <title>Big tag</title>  
  5.  </head>  
  6.  <body>  
  7.    <h2>Example of HTML big tag</h2>  
  8.     <p style="color:#ff4040">This is paragraph with normal font size</p>  
  9.     <p style="color:#00bfff">  
  10.         <big>This is paragraph with font size greater than the previous content</big>  
  11.     </p>  
  12.   </body>  
  13. </html>  


Output:

HTML big tag

Increasing Font-size using CSS property:

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <style>  
  5.           .fsize{  
  6.         font-size: 18px;  
  7.         color: red;  
  8.         }  
  9.     </style>  
  10. </head>  
  11. <body>  
  12.     <h2>Example to change font size using CSS</h2>  
  13.     <p>The paragraph content with default font size</p>  
  14.     <p class="fsize">The paragraph content with CSS to increase font size</p>  
  15. </body>  
  16. </html>  


Output:HTML big tag

Attribute

Tag-specific Attribute:

The <big> element does not contain any specific attribute.

Global Attribute

The <big> element supports the Global Attribute in HTML.


HTML <blockquote> tag

HTML <blockquote> tag is used to define a block of text which is quoted from another source. The Browser usually displays the content within <blockquote> tag as indented text.

If you want to insert a long quote then use <blockquote> and for short or inline quote use <q> tag.

Syntax

  1. <blockquote> quoted text......</blockquote>  

Following are some specifications about the <blockquote> tag

DisplayBlock
Start tag/End tagBoth start and End tag
UsageSemantic/textual

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Blockquote tag</title>  
  5. </head>  
  6. <body>  
  7.     <h2>Example of blockquote tag</h2>  
  8.     <p>A Great Motivational Quote :</p>  
  9.    <blockquote cite="https://www.brainyquote.com/authors/erin_cummings">  
  10.     <p>  
  11.      At the end of the day, you are solely responsible for your success and your failure. And the sooner you realize that, you accept that, and integrate that into your work ethic, you will start being successful. As long as you blame others for the reason you aren't where you want to be, you will always be a failure.  
  12.      </p>  
  13.    </blockquote>  
  14. <cite>Erin Cummings</cite>  
  15. </body>  
  16. </html>  

Test it Now

Output:HTML blockquote tag

Styling <blockquote> tag

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Blockquote tag</title>  
  5.    <style>  
  6.     blockquote{  
  7.         text-align: justify;  
  8.         background-color: #F7EAE9;  
  9.                            border-radius: 4px;  
  10.                            margin-right: 25px;}  
  11.     cite{  
  12.       margin-left: 15px;}  
  13.    </style>  
  14. </head>  
  15. <body>  
  16.     <h2>Example of blockquote tag</h2>  
  17.     <p>A Great Motivational Quote:</p>  
  18.    <blockquote cite="https://www.brainyquote.com/authors/erin_cummings">  
  19.     <p>  
  20.      At the end of the day, you are solely responsible for your success and your failure. And the sooner you realize that, you accept that, and integrate that into your work ethic, you will start being successful. As long as you blame others for the reason you aren't where you want to be, you will always be a failure.  
  21.      </p>  
  22.    </blockquote>  
  23. <cite>-Erin Cummings</cite>  
  24. </body>  
  25. </html>  


Note: We have used CSS property margin-right: 25px to change the indentation applied to the text. You can also use margin-left or margin shorthand property.

Output:

HTML blockquote tag

Attribute

Tag specific attribute

AttributevalueDescription
citeHTML blockquote tagURLIt is used to specify the URL of the source from where the quote is taken.

Global attributes

The <blockquote> tag supports all the global attributes in HTML.

Event attributes

The <blockquote> tag supports all events attributes in HTML.

HTML <body> tag

HTML <body> tag defines the main content of an HTML document which displays on the browser. It can contain text content, paragraphs, headings, images, tables, links, videos, etc.

The <body> must be the second element after the <head> tag or it should be placed between </head> and </html> tags. This tag is required for every HTML document and should only use once in the whole HTML document.

Syntax

  1. <body> Place your Content here........</body>  

Following are some specifications about the <body> tag

DisplayInline
Start tag/End tagBoth start and End tag
UsageStructural

Example

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.  <title>Body Tag</title>  
  5. </head>  
  6. <body>  
  7.  <h2>Example of body tag</h2>  
  8.  <p>This paragraph is written between the body tag</p>  
  9. </body>  
  10. </html>  


Output:HTML body tag

Attribute

Tag specific Attributes

AttributeValueDescription
alinkcolorIt defines the color of the active link in a document. (Not supported in HTML5)
backgroundURLIt determines the background image for the document. (Not supported in HTML5)
bgcolorcolorIt determines the background color of the content. (Not supported in HTML5)
linkcolorIt determines the color of the unvisited link. (Not supported in HTML5)
textcolorIt determines the color of the text in the document. (Not supported in HTML5)
vlinkcolorIt determines the color of the visited link. (Not supported in HTML5)
onloadFunction call on page loading
onunloadFunction call when user leaves the page
onfocusFunction call when document receives focus by user.
onblurFunction call when document loses focus by user.

Global Attribute

The <body> attribute supports global attribute in HTML.

Event Attribute

The <body> attribute supports Event attributes in HTML.

HTML <br> tag

The <br> tag in HTML document is used to create a line break in a text.

It is generally used in poem or address where the division of line is necessary. It is an empty tag, which means it does not need a company of end tag. If you place the <br> tag in the HTML code, then it works the same as pressing the enter key in a word processor.

Note: Don't use br tag for the margin between two paragraphs, use CSS margin property instead.

Syntax

  1. Text <br> Text  

Difference between HTML <br> and <br/>

You can use HTML br tag two ways: <br> or <br/>. It is recommended to use closed br tag <br/> because it is supported in HTML and XHTML both.

Example 1:

 

  1. <!DOCTYPE HTML> 
  2. <html>  
  3. <head>  
  4. <title>  
  5. Example of BR tag  
  6. </title>  
  7. </head>    
  8. <body>    
  9. <p>If you want to break a line <br> in a paragraph, <br> use the BR element in <br> your HTML document. </p>    
  10. </body>  
  11. </html>    


Output:

HTML br tag

Example 2: The following example uses the <br> tag in the address:

  1. <!DOCTYPE HTML>  
  2. <html>  
  3. <head>  
  4. <title>  
  5. Example of BR tag in Address  
  6. </title>  
  7. </head>    
  8. <body> <font color="green"> <!-The color attribute displays the color of following address in green -->   
  9. <p>Central park <br>   
  10. D.M Road, <br>  
  11. New Delhi, <br>  
  12. India <br>   
  13. </body>  
  14. </html>    


Output:

HTML br tag

Example 2: The following example uses the <br> tag in the poem:

  1. <!DOCTYPE HTML>  
  2. <html>  
  3. <head>  
  4. <title>  
  5. Example of BR tag in Poem  
  6. </title>  
  7. </head>    
  8. <body> <font color="green">   
  9. <center> Dreams  
  10.   
  11. </center>  
  12. Hold fast to dreams <br>  
  13.   
  14. For if dreams die <br>  
  15.   
  16. Life is a broken-winged bird <br>  
  17.   
  18. That cannot fly. <br>  
  19.    
  20. Hold fast to dreams <br>  
  21.   
  22. For when dreams go <br>  
  23.   
  24. Life is a barren field <br>  
  25.   
  26. Frozen with snow. <br>  
  27. </body>  
  28. </html>    


Output:

HTML br tag


HTML Button Tag

The <button> tag is used to create a clickable button within HTML form on your webpage. You can put content like text or image within the <button>........</button> tag.

You should always specify the type attribute for a <button> tag. Different browsers use different default type for the button element.

HTML Button tag can be used inside and outside the form.

If you use it inside the form, it works as the submit button. You can also use it as reset button.

If you use it outside the form, you can call JavaScript function on it.


HTML Button Tag Example

Let's see the code to display the button.

  1. <button name="button" type="button">Click Here</button>  

Output:


HTML Button Example: Calling JavaScript Function

Let's see the code to call JavaScript function on button click.

  1. <button name="button" value="OK" type="button" onclick="hello()">Click Here</button>  
  2. <script>  
  3. function hello(){  
  4. alert("hello javatpoint user");  
  5. }  
  6. </script>  

Output:

HTML Button Example: Submit Form

Let's see the code to submit form on button click.

  1. <form>  
  2. Enter Name:<input type="text" name="name"/><br/>  
  3. <button>Submit</button>  
  4. </form>  

Output:

Enter Name:

HTML Button Example: Reset Form

Let's see the code to submit form on button click.

 

  1. <form> 
  2. Enter Name:<input type="text" name="name"/><br/>  
  3. <button type="reset">reset</button>  
  4. </form>  

Output:

Enter Name:

Attributes of HTML Button Tag

<button> tag supports all global attributes and some specific additional attributes.

There is given a list of HTML button tag attributes.

AttributeDescription
autofocusIt specifies that a button should automatically get focus while the loading of the page.
disabledIt specifies that a button shuld be disabled.
formIt specifies one or more forms that the button belongs to.
formactionIt is used for submit type. It specifies where to send the form data when form is submitted.
formmethodIt specifies how to send form-data.
formenctypeIt specifies how form-data should be encoded before sending it to server.
formnovalidateIt specifies that the form data should not be validated on submission.
formtargetIt specifies that where to display the response after submitting the form.
nameIt specifies the name of the button.
typeIt specifies the type of the button.
valueIt specifies the value of the button.

HTML Canvas Tag

The HTML canvas element provides HTML a bitmapped surface to work with. It is used to draw graphics on the web page.

The HTML 5 <canvas> tag is used to draw graphics using scripting language like JavaScript.

The <canvas> element is only a container for graphics, you must need a scripting language to draw the graphics. The <canvas> element allows for dynamic and scriptable rendering of 2D shapes and bitmap images.

It is a low level, procedural model that updates a bitmap and does not have a built-in scene. There are several methods in canvas to draw paths, boxes, circles, text and add images.

How to create a HTML canvas?

A canvas is a rectangle like area on an HTML page. It is specified with canvas element. By default, the <canvas> element has no border and no content, it is like a container.

  1. <canvas id = "mycanvas" width ="200" height ="100"> </canvas>  

HTML 5 Canvas Tag Example

  1. <canvas id="myCanvas1" width="300" height="100" style="border:2px solid;">  
  2. Your browser does not support the HTML5 canvas tag.  
  3. </canvas>  

Output:

Note: It is always necessary to specify the id attribute and the height & width attribute to define the size of the canvas. You can have multiple canvas elements on one HTML page.


Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<canvas>YesYesYesYesYes

HTML Canvas Tag with JavaScript

A canvas is a two dimensional grid.

Coordinates (0,0) defines the upper left corner of the canvas. The parameters (0,0,200,100) is used for fillRect() method. This parameter will fill the rectangle start with the upper-left corner (0,0) and draw a 200 * 100 rectangle.

  1. <canvas id="myCanvas" width="250" height="150" style="border:1px solid #c3c3c3;">  
  2. Your browser does not support the HTML5 canvas tag.  
  3. </canvas>  
  4. <script>  
  5. var c = document.getElementById("myCanvas");  
  6. var cctx = c.getContext("2d");  
  7. ctx.fillStyle = "#FF0000";  
  8. ctx.fillRect(0,0,200,100);  
  9. </script>  

Output:


Drawing Line on Canvas

If you want to draw a straight line on the canvas, you can use the following two methods.

moveTo(x,y): It is used to define the starting point of the line.

lineTo(x,y): It is used to define the ending point of the line.If you draw a line which starting point is (0,0) and the end point is (200,100), use the stroke method to draw the line.

  1. <canvas id="myCanvasLine" width="200" height="100" style="border:1px solid #d3d3d3;">  
  2. Your browser does not support the HTML5 canvas tag.</canvas>  
  3. <script>  
  4. var c = document.getElementById("myCanvasLine");  
  5. var cctx = c.getContext("2d");  
  6. ctx.moveTo(0,0);  
  7. ctx.lineTo(200,100);  
  8. ctx.stroke();  
  9. </script>  

Output:


Drawing Circle on Canvas

If you want to draw a circle on the canvas, you can use the arc() method:

  1. arc(x, y, r, start, stop)   

To sketch circle on HTML canvas, use one of the ink() methods, like stroke() or fill().

  1. <canvas id="myCanvasCircle" width="200" height="100" style="border:1px solid #d3d3d3;">  
  2. Your browser does not support the HTML5 canvas tag.</canvas>  
  3. <script>  
  4. var c = document.getElementById("myCanvasCircle");  
  5. var cctx = c.getContext("2d");  
  6. ctx.beginPath();  
  7. ctx.arc(95,50,40,0,2*Math.PI);  
  8. ctx.stroke();  
  9. </script>  

Output:

Drawing text on canvas

There are property and methods used for drawing text on the canvas.

font property: It is used to define the font property for the text.

fillText(text,x,y) method: It is used to draw filled text on the canvas. It looks like bold font.

strokeText(text,x,y) method: It is also used to draw text on the canvas, but the text is unfilled.

Let's see fillText() method example.

  1. <canvas id="myCanvasText1" width="300" height="100" style="border:1px solid #d3d3d3;">  
  2. Sorry! Your browser does not support the HTML5 canvas tag.</canvas>  
  3. <script>  
  4. var c = document.getElementById("myCanvasText1");  
  5. var cctx = c.getContext("2d");  
  6. ctx.font = "30px Arial";  
  7. ctx.fillText("Hello JavaTpoint",10,50);  
  8. </script>  

Output:

Let's see strokeText() method example.

  1. <canvas id="myCanvasText2" width="300" height="100" style="border:1px solid #d3d3d3;">  
  2.  Sorry!Upgrade your browser. It does not support the HTML5 canvas tag.</canvas>  
  3. <script>  
  4. var c = document.getElementById("myCanvasText2");  
  5. var cctx = c.getContext("2d");  
  6. ctx.font = "30px Arial";  
  7. ctx.strokeText("Hello SloganTech",10,50);  
  8. </script>  

Output:


HTML <caption> tag

HTML <caption> tag is used to add a caption or title of an HTML table. It should be used inside the <table> element and just after the <table> start tag. A table may contain only one <caption> element.

Syntax

  1. <caption>Table title...</caption>  

Following are some specifications about the <caption> tag

DisplayInline
Start tag/End tagBoth start and End tag
Usagetextual

Example 1

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Caption Tag</title>  
  5.     <style>  
  6.         table, td, th {  
  7.         border: 3px solid gray;  
  8.         border-collapse: collapse;}  
  9.     </style>  
  10.  </head>  
  11.  <body>  
  12.     <h2>Example of Caption tag</h2>  
  13.    <table width="800">  
  14.       <caption>Employee Details</caption>  
  15.       <thead>  
  16.         <tr>  
  17.             <th>Sr. No.</th>  
  18.             <th>Name</th>  
  19.             <th>Email</th>  
  20.           </tr>  
  21.         </thead>  
  22.        <tbody>  
  23.         <tr>  
  24.             <td>1.</td>  
  25.             <td>Ankit Pandey</td>  
  26.             <td>ankit2@gmail.com</td>  
  27.         </tr>  
  28.         <tr>  
  29.             <td>2.</td>  
  30.             <td>Ashvini Kumar</td>  
  31.             <td>ashvini@gmail.com</td>  
  32.         </tr>  
  33.         <tr>  
  34.             <td>3.</td>  
  35.             <td>Swati Sharma</td>  
  36.             <td>swati8@gmail.com</td>  
  37.         </tr>  
  38.     </tbody>  
  39. </table>  
  40. </body>  
  41. </html>  

Output:

HTML caption tag

Attribute

Tag-specific Attributes

AttributeValueDescription
align
  • top
  • bottom
  • left
  • right
It aligns the caption with respect to table

HTML <center> tag (Not Supported in HTML5)

The HTML <center> is a block level element which contains both block level and inline contents within it. The content written between the <center> elements will be displayed at the middle of the page.

The <center> tag has been deprecated in HTML 4 and obsolete in HTML5.

NOTE: The <center> tag is deprecated now so instead of that you can use CSS property text-align: center; to achieve the same result.

Syntax

  1. <center>Add Content Here....</center>  

Following are some specifications about the <center> tag

DisplayInline
Start tag/End tagBoth start and End tag
Usagetextual

Example

Using <center> tag


  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Center tag</title>  
  5.  </head>  
  6.  <body>  
  7.     <h2>Example of center tag</h2>  
  8.     <center>This content is displayed in the middle of page, but try to use CSS property to align the content as this tag is deprecated now.</center>  
  9.   </body>  
  10. </html>  

Using CSS

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>Center tag</title>  
  5.     <style >  
  6.         h2{  
  7.          text-align: center;}  
  8.     </style>  
  9.  </head>  
  10.  <body>  
  11.       <h2>Example of center tag</h2>  
  12.       <p>This content is align centered using CSS property</p>  
  13.   </body>  
  14. </html>  

Output:

HTML center tag

Attribute

HTML <center> tag does not contain any specific attribute in HTML but it supports the Global Attribute (till <center> tag is not removed completely).













Post a Comment

0 Comments

Recents Post

Exploring Paidwork - Your Gateway to Earning Online