Category Archives: html

HTML Tags

Hyper Text Markup Language is a set of special markers formally know as HTML Markup Tags which defines the style and structure of the document.HTML Markup Tags are what which distinguish HTML Code from normal text. HTML Tags are basically short codes placed between opening and closing angle brackets (< and >) with an optional list of tag attributes.

Syntax

Using HTML Tags we can perform cool stuffs like adding stylish text, images and tables in webpage. Different tags have different functions.HTML tags never displays when we view our page using a browser, but their effects is visible.

HTML Tags can be of two types –

Paired Tags

A tag is said to be paired tag if it comes along with a companion tag.HTML Tags usually come in pairs, one is opening tags and other is closing tags, closing tag is same as start tag, with a forward slash before the tag name. The actual text is placed in between.

Singular Tags

Singular or stand-alone tags does not have the companion tag. For example <BR> tag used to insert a line break, it does not require any closing tag.

 

HTML Comments

Comments in any programming language is a block of notes or remarks, can be placed anywhere in the code to assist the programmer to understand why is this particular block of code has been written. HTML Comments increase the readability of the code, and helps other programmer to understand the code written by other programmer if it is properly commented.It is always a good practice to put comments into your source code.

Advantages of putting comments in HTML

  • Comment out code temporarily rather than removing when it is not complete and could be used in future.
  • Helps to put remarks on block of code.
  • Helps other programmer to understand the source code.
  • It helps debugging the code.

HTML Comments can be placed anywhere in the HTML file, it could be inside the head section or could be inside the body section, or in between the head and the body.HTML Comment Tags are different than other HTML Tags. HTML Comments always start with <!-- and end with -->. Comments never displayed on the browser.

Syntax

 

 

HTML Scripts

HTML Scripts gives us way to embed or include client side script into the HTML Document. HTML script (<script>…</script>) tag is used to include a block of client side script or to call it from external source.

Internal Script

You can define your custom block or function of client side scripting language inside a HTML Document itself.

Example:

External Script

If you have ready to use client side script library or custom script that you want to reuse then you can call into the HTML Document.

Example:

 

 

HTML Styles

When it comes to styling a web page or HTML Elements , this whole responsibility is care taken by the CSS. CSS gives web designers and developers full control over the look and feel and the layout of the web pages.CSS can be added to HTML Element using the <style>…</style> tag or using “style=’ ‘ ” attribute.

There are four different ways CSS can be applied to any HTML Element –

  • Inline CSS
  • Embedded CSS
  • External CSS
  • Imported CSS

Inline CSS

In Inline CSS method all the styling applied to the HTML Element are defined inside the HTML Tag.

Example:

Embedded CSS

In this method styles are embedded inside the HTML document using the ‘style’ element (usually within the <head> tag).

Example:

External CSS

In this method all CSS that you want to use throughout your website are declared in a external style sheet which is a separate file that file typically has extension of ‘css’ . You can then include this external style sheet in any or all of your HTML pages.

Example:

Imported CSS

External Stylesheets can also be imported into an HTML document using @Import rule.

Example:

 

 

HTML Backgrounds

HTML Backgrounds gives us a way to set background image for HTML elements like – HTML Table.

We can set various type of background like solid color, transparent background, gradient etc.HTML Backgrounds grow or shrink dynamically as the HTML element grows or shrinks.

Example:

Output:

Repeating Background

Sometimes when we use a image for the background we get into trouble when HTML element’s height or width grows comparatively to the background image. In this case we can repeat the background image in X or Y direction.

 

HTML Forms

HTML Forms gives a way to web developers to collect the information from the visitors. HTML Forms can collect input from the visitors and pass it to the server using the server side scripting languages like- php,asp etc.

You must be familiar to some common forms available on the websites. Example – Registration form, Contact Us form, Inquiry Form etc.

HTML Form supports various input elements to take the input from the visitor like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.

HTML Form is defined using the <form></form> tags. The actual input elements are placed in between these two tags.

Form Attributes

Attribute Value
name This attribute specifies the name of the form.
action This attribute specifies the path of the script where the collected information will be submitted.
method This attribute specifies method by which data will be passed to server. Example -GET and POST
enctype This attribute species encryption type for the data before it is passed to the server.

HTML Colors

HTML Colors allows us to set a color for HTML Elements and for various attributes of these HTML Entities. For example we can set color for text color, Border, Background etc.

HTML Color values can be assigned in following three format :

Hex or Hexadecimal Code Notation

The Hex or Hexadecimal Code Notation is most preferable method for defining color values.Hex color code starts with the hash (#) character, followed by three or six hexadecimal digits in RGB format. For example, the hexadecimal color value for white is #FFFFFF, or #FFF in shorthand. Hexadecimal code notation supports a more range of colors than the keyword system.

Format Syntax Example
Hex Code #RRGGBB or #RGB p{color:#FFFFFF;} or p{color:#FFF;}

RGB Notation

Tough hex codes are more popular in HTML but many designers prefers to use RGB color model. A color is defined by the amount of Red, Green and Blue, RGB color values supported by the all major browsers.In RGB a color value can be defined using 0 to 255 integer value for the intensity of red, green and blue values that comprise our RGB colors (or using percentages instead).

Format Syntax Example
RGB% or RGB Absolute rgb(rrr%,ggg%,bbb%) or rgb(rrr,ggg,bbb) p{color:rgb(50%,50%,50%);} or p{color:rgb(0,0,255);}

Color Keywords or Color Name

Basic color keyword or color name notation is simplest method to define a color value and has been around for a long time,but the color names are limited to 16 values but, but can be expanded using an extended palette.

Format Syntax Example
keyword or name red, blue etc. p{color:green;}

List of 17 official HTML color names with their hex RGB value and their decimal RGB value.

Color Name Hex Code RGB Decimal Code RGB
Maroon 800000 128,0,0
Red FF0000 255,0,0
Orange FFA500 255,165,0
Yellow FFFF00 255,255,0
Olive 808000 128,128,0
Green 008000 0,128,0
Purple 800080 128,0,128
Fuchsia FF00FF 255,0,255
Lime 00FF00 0,255,0
Teal 008080 0,128,128
Aqua 00FFFF 0,255,255
Blue 0000FF 0,0,255
Navy 000080 0,0,128
Black 000000 0,0,0
Gray 808080 128,128,128
Silver C0C0C0 192,192,192
White FFFFFF 255,255,255

Browser Safe Colors

List of 216 browser safe colors for a 256 color palette system –

000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

HTML Layouts

Presenting information on a HTML Document in organized manner is all about the HTML Document Layout. HTML Layout is more about defining the structure of the web page. HTML document layout plays very important role in presenting the information. Its upto the web designers skill how best layout for the web page then can deliver.

There are lots layout option available now a days, most common part of the standard layout includes the banner space, header,footer,navigation, left pane,right pane etc.

HTML layout with tables

HTML Table is the most common and easy method to create layouts, with a proper use of table rows ,columns and their attribute like colspan and rowspan we can achieve good layouts.

Take a look at following HTML layout, this can be achieved using a table having 3 rows and 2 columns. Header and footer column spans full columns (using the colspan attribute).

Example:

Output:

Header
Left menu Main body
Footer

HTML layout with DIV, SPAN and CSS

We can achieve same layout using block elements like DIV or SPAN with the help of CSS.

Example:

Output:

Header
Left menu
Main body
Footer

HTML Lists

HTML List Element used to display numbered or bulleted points on a web page, CSS List Properties helps us to control list type, position, style etc for the HTML List Elements.

List Element can be of two type:

Unordered lists – List items are presented with bullets.

Ordered lists – List items are presented with numbers or letters in a specific order.

Following is a list of basic five CSS properties for HTML List Element –

Property Description
list-style-type This property specifies the type of marker to be added to the HTML List Item. Possible Values – disc,circle,square,decimal,lower-roman etc.
list-style-position This property specifies the list-item markers will added inside or outside of the HTML List Item. Possible Values – inside,outside
list-style-image This property specifies an image as marker for the HTML List Item.
list-style This property specifies all the properties for HTML List Item in one declaration. This is know as shorthand property too.
marker-offset This property specifies space between marker and the HTML List Item content.

List Style Type

This property specifies the type of marker to be added to the HTML List Item.

Example Code:

Output:

  • List item one
  • List item two
  1. List item one
  2. List item two

List Style Position

This property specifies the list-item markers will added inside or outside of the HTML List Item. Possible Values.

Example Code:

Output:

  • List item one
  • List item two
  • List item one
  • List item two
  1. List item one
  2. List item two
  1. List item one
  2. List item two

List Style Image

This property specifies an image as marker for the HTML List Item.

Example Code:

Output:

  • List item one
  • List item two
  1. List item one
  2. List item two

List Style

This property specifies all the properties for HTML List Item in one declaration. This is know as shorthand property too.

Example Code:

Output:

  • List item one
  • List item two
  1. List item one
  2. List item two

Marker Offset

This property specifies space between marker and the HTML List Item content.

Example Code:

 

Output:

  • List item one
  • List item two
  1. List item one
  2. List item two

HTML Definition Lists

HTML definition list is another set of tag used to list items, but a definition list best suited for presenting glossary or indexing.

Tag used in definition list –

  • <dl> – This tag indicate the opening of the list.
  • <dt> – This tag defines definition term for list item.
  • <dd> – This tag used to give definition of the list item.
  • </dl> – This tag indicate the end of the list.

Example:

Output:

HTML
This stands for Hyper Text Markup Language
AJAX
This stands for Asynchronous Javascript and XML

HTML Frames

HTML Frames gives us a way to merge multiple HTML Documents in a single HTML Document. HTML Frames splits the browser window into multiple panes or rectangular sections, each pane can contain separate HTML Document.This division process is same as for the HTML Table.

HTML Frameset (<frameset>) element is used instead of HTML Body (<body>) tag to split the browser screen into multiple pane, and each pane is defined by HTML Frame (<frame>) element.

Example:

Output:

HTML Frameset Attributes

Attribute Description
cols This attribute specifies the number of columns in frameset along with their width separated by the comma.Width can be specified in percentage or pixels
rows This attribute specifies the number of rows in frameset along with their height separated by the comma.Height can be specified in percentage or pixels
border This attribute specifies the width of the border for the frames. Value “0” means no border.

Example-1:

Output:

col 1, row 1 col 2
col 1, row 2

Example-2:

Output:

row 1, col 1 row 1, col 2
row 2

HTML Frame Attributes

Attribute Description
src This attribute specifies URL of the source HTML Document. This can be absolute or relative path.
frameborder This attribute specifies whether or not the frame border shown. Possible values either 1 (yes) or 0 (no).
noresize This attribute specifies whether or not user will be able to resize the frame.
scrolling This attribute specifies whether or not scrollbars will appear for the frame.

Inline Frames – The HTML <iframe> Element:

We can create an inline frame within the HTML Document using the <iframe> tag. HTML <iframe> gives us a way to call HTML Document inside another HTML Document.HTML <iframe> element defines a rectangular region inside the HTML document in that region browser will render a separate HTML document, including scrollbars and borders.

Attribute Description
src This attribute specifies URL of the source HTML Document. This can be absolute or relative path.
width This attribute specifies frame width.Width can be specified in percentage or pixels.
Height This attribute specifies frame height.Height can be specified in percentage or pixels.
frameborder This attribute specifies whether or not the frame border shown. Possible values either 1 (yes) or 0 (no).
scrolling This attribute specifies whether or not scrollbars will appear for the frame.

HTML Tables

HTML Table Element used to represent the information in tabular format on the web page that enhance the readability of the information. HTML Tables Elements can also be used to create layouts or structure of the webpages.

Like any other table HTML Tables are composed of one or many rows and rows in turns composed of one or many cells. Table cells can contain the actual information it can be text,image, HTML Element or could be HTML Table itself.

Standard HTML Table Structure –

Column A Column B Column C
Begin <table>
Caption <caption> Table Caption </caption>
Headers <tr>
<th> H1 </th> <th> H2 </th> <th> H3 </th>
<td> A1 </td> <td> B1 </td> <td> C1 </td>
<td> A2 </td> <td> B2 </td> <td> C2 </td>
<td> A3 </td> <td> B3 </td> <td> C3 </td>
</tr>
Row 1 <tr> </tr>
Row 2 <tr> </tr>
Row 3 <tr> </tr>
End </table>

 

HTML Tables can be easily created using <table>..</table> tag.

Basic tags required to create a HTML Table –

Tag Description
<table> Represent the begining of table element.
<th>…</th> This tag is used to specify the table column heading.
<tr>…</tr> This tag is used to represent starts and ends of a table row
<td>…</td> This tag is used to represent starts and ends of a table cell
</table> Represent the end a table element.

Example:

Output:

cell one cell two
cell three cell four

Table Border

Grids/Borders can be set for outside boundaries of the table and table cells using table “Border” attribute, we can pass a numerical value for the this attribute and specifies the thickness of the border, value "0" specifies no borders to be drawn.

Example:

Output:

cell one cell two
cell three cell four

Table Heading

Table Heading allows us to set heading for the columns in the table,using <th>…</th> tag we can define heading cells for column. The Heading cell is same as other cells in table and can be manipulated in the same way. The text between heading tags will displayed in bold and will be aligned centered within the table cell.

Example:

Output:

Column One Column two
cell one cell two
cell three cell four

Table Colspan

This attribute enable us to specify the span of the cell across the number of columns. We can assign numerical value to the attribute, which means how many columns width will this cell occupy, it depends on how many columns we wish to cell span across.

Example:

Output:

Column One Column two
cell one
cell three cell four

Table Rowspan

This attribute enable us to specify the span of the cell across the number of rows. We can assign numerical value to the attribute, which means how many rows height will this cell occupy, it depends on how many rows we wish to cell span across.

Example:

Output:

cell one cell one
cell four

HTML Email Links

HTML Email Links allows us to create hyperlinks to an email address. Links to an email address is created using the HTML <a> </a> tag while in this case instead of passing URLs we put recipient’s email address. mailto attribute is used to specify the email address in your anchor tag.

Syntax:

Output:

Send Email

Send Query

Now when user clicks on any of this link it will launch default Email Client on our computer. Example: outlook express