HTML Elements & Attributes

HTML elements form the building blocks of all websites.

Everything that comes in-between and includes the tag is defined as element of that particular tag.

For example,

<HTML> Element – Contains element of the whole document.

<HEAD> Element –Contains the title of the document

i.e. <title>ProgrammingTute</title>

 

You will see that ProgrammingTute will appear on the title bar of the window.

Also it contains some of the elements like

i)              <base> tag-used to create base url for all links on the page.

ii)             <script> tag-used to include java script inside the document.

iii)            <object> tag-used to include image, mp3 files etc.

iv)           <link> tag-link to an external file like javascript file etc.

v)            <meta> tag-it’s like giving information about data(metadata information)

vi)           <style> tag-used to include stylesheet inside the document.

 

<BODY> Element- Contains the content of the document. It may contain anything like paragraph, forms and tables.

 

Tags can also have attributes, which provide additional information about an element.

Attributes should appear inside the opening tag and their value is always be enclosed in quotes.

For example,

<a href="http://www.programmingtute.com">This is a link</a>

 

Some of the main attributes which gets repeated are class, id, style, title and dir.

Class – It is used to Specify the class name of particular element inorder to associate with a with a style sheet. You no need to worry about this until you start learning CSS.

Example: class=”default”

Id– To differentiate between two elements with same name and to specify unique id for an element, we can use this attribute.

Example:

<p id="Pt">ProgrammingTute</p>

Style – We can specify CSS style for an element by using this style attribute.

For example, “style=’height:200px;width:300px”

Title– The title for the element has to be given in this attribute. Also it can be used as tooltip text for a particular element.

Dir– It tells the browser the direction in which the text should flow inside the content.

For example,

<p dir="ltr">Write this text left-to-right!</p>

Ltr-Left-to-Right

Rtl-Right-to-left

Auto– browser choice based on the content displayed (if nothing is given).

Lang– It specifies the language of the element’s content.

 

If it is included inside the <html> tag, it specifies the language used within the document.

If it is included inside the other tags, then it specifies the language used within those tags.

For example,

<p lang="en">This page is using English language</p>

 

Posted on July 12, 2014 in HTML

Share the Story

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top