Monday, April 30, 2012

HTML Advanced tutorial 26 : HTTP Status Messages

When a browser requests a service from a web server, an error might occur. This kind of error is shown using Status Message. Below a list of HTTP status messages that might be returned from server. These Status Messages are categories into different tables based on their type of responses.

Information :

These types of HTTP Status Message starts with 1xx. Their details are below.

Message: Description:
100 Continue The server has received the request headers, and the client should proceed to send the request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Checkpoint Used in the resumable requests proposal to resume aborted PUT or POST requests

Successful :

These types of HTTP Status Message starts with 2xx. Their details are below.

Message: Description:
200 OK The request is OK. This is the standard response for successful HTTP requests.
201 Created The request has been fulfilled, and a new resource is created 
202 Accepted The request has been accepted for processing, but the processing has not been completed
203 Non-Authoritative Information The request has been successfully processed, but is returning information that may be from another source
204 No Content The request has been successfully processed, but is not returning any content
205 Reset Content The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view
206 Partial Content The server is delivering only part of the resource due to a range header sent by the client

Redirection :

These types of HTTP Status Message starts with 3xx. Their details are below.

Message: Description:
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five addresses  
301 Moved Permanently The requested page has moved to a new URL 
302 Found The requested page has moved temporarily to a new URL 
303 See Other The requested page can be found under a different URL
304 Not Modified Indicates the requested page has not been modified since last requested
306 Switch Proxy No longer used
307 Temporary Redirect The requested page has moved temporarily to a new URL
308 Resume Incomplete Used in the resumable requests proposal to resume aborted PUT or POST requests

Client Error :

These types of HTTP Status Message starts with 4xx. Their details are below.

Message: Description:
400 Bad Request The request cannot be fulfilled due to bad syntax
401 Unauthorized The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided
402 Payment Required Reserved for future use
403 Forbidden The request was a legal request, but the server is refusing to respond to it
404 Not Found The requested page could not be found but may be available again in the future
405 Method Not Allowed A request was made of a page using a request method not supported by that page
406 Not Acceptable The server can only generate a response that is not accepted by the client
407 Proxy Authentication Required The client must first authenticate itself with the proxy
408 Request Timeout The server timed out waiting for the request
409 Conflict The request could not be completed because of a conflict in the request
410 Gone The requested page is no longer available
411 Length Required The "Content-Length" is not defined. The server will not accept the request without it 
412 Precondition Failed The precondition given in the request evaluated to false by the server
413 Request Entity Too Large The server will not accept the request, because the request entity is too large
414 Request-URI Too Long The server will not accept the request, because the URL is too long. Occurs when you convert a POST request to a GET request with a long query information 
415 Unsupported Media Type The server will not accept the request, because the media type is not supported 
416 Requested Range Not Satisfiable The client has asked for a portion of the file, but the server cannot supply that portion
417 Expectation Failed The server cannot meet the requirements of the Expect request-header field

Server Error :

These types of HTTP Status Message starts with 5xx. Their details are below.

Message: Description:
500 Internal Server Error A generic error message, given when no more specific message is suitable
501 Not Implemented The server either does not recognize the request method, or it lacks the ability to fulfill the request
502 Bad Gateway The server was acting as a gateway or proxy and received an invalid response from the upstream server
503 Service Unavailable The server is currently unavailable (overloaded or down)
504 Gateway Timeout The server was acting as a gateway or proxy and did not receive a timely response from the upstream server
505 HTTP Version Not Supported The server does not support the HTTP protocol version used in the request
511 Network Authentication Required The client needs to authenticate to gain network access

HTML Advanced tutorial 27 : HTML Language Code  >>
<<  HTML Advanced tutorial 25 : HTML URL Encoding

Saturday, April 28, 2012

HTML Advanced tutorial 25 : HTML URL Encoding

URL encoding converts characters into a format that can be transmitted over the Internet. Web browsers request pages from web servers by using a URL. The URL is the address of a web page, e.g http://www.yoursite.com.

URLs can only be sent over the Internet using the ASCII character-set. Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format. URL encoding replaces non ASCII characters with a "%" followed by two hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a + sign.

URL Encoding Examples

Character            URL-encoding
€                           %80
£                           %A3
©                          %A9
®                          %AE
À                          %C0
Á                          %C1
                          %C2
à                          %C3
Ä                          %C4
Å                          %C5


HTML Advanced tutorial 26 : HTTP Status Messages  >>
<<  HTML Advanced tutorial 24 : HTML URL

HTML Advanced tutorial 24 : HTML URL

A URL ( Uniform Resource Locator ) is another word for a web address. A URL can be composed of words,  or an Internet Protocol ( IP ) address. Most people enter the name of the website when surfing, because names are easier to remember than numbers.

When you click on a link in an HTML page, an underlying <a> tag points to an address on the world wide web. A URL is used to address a document (or other data) on the world wide web. A web address, like this, http://www.yoursite.com/html/index.html follows these syntax rules.

scheme://host.domain:port/path/filename


Below is the explanation of terms.

scheme -    defines the type of Internet service. The most common type is http
host -         defines the domain host (the default host for http is www)
domain -    defines the Internet domain name, like yoursite.com
:port -        defines the port number at the host (the default port number for http is 80)
path -        defines a path at the server (If omitted, the document must be stored at the root directory of the web site)
filename -   defines the name of a document/resource

Common URL Schemes
These are lists some common schemes.

http  =  HyperText Transfer Protocol :
Common web pages starts with http://. not encrypted

https  =  Secure HyperText Transfer Protocol:
Secure web pages. All information exchanged are encrypted

ftp  =  File Transfer Protocol:
For downloading or uploading files to a website. Useful for domain maintenance

file:
A file on your computer

HTML Advanced tutorial 25 : HTML URL Encoding  >>
<<  HTML Advanced tutorial 23 : HTML Entities

Friday, April 27, 2012

HTML Advanced tutorial 23 : HTML Entities

Some characters are reserved in HTML. It is not possible to use the less than (<) or greater than (>) signs in your text, because the browser will mix them with tags. To actually display reserved characters, we must use character entities in the HTML source code. A character entity may looks like this.
&entity_name;
OR
&#entity_number;
To display a less than sign we must write: &lt; or &#60; The advantage of using an entity name, instead of a number, is that the name is easier to remember. However, the disadvantage is that browsers may not support all entity names (the support for entity numbers is very good).

Non-breaking Space
A common character entity used in HTML is the non-breaking space (&nbsp;). Browsers will always truncate spaces in HTML pages. If you write 10 spaces in your text, the browser will remove 9 of them, before displaying the page. To add spaces to your text, you can use the &nbsp; character entity.

HTML Useful Character Entities

Entity names are case sensitive. Following is list of entity names with their description.

Result Description Entity Name Entity Number
non-breaking space &nbsp; &#160;
< less than &lt; &#60;
> greater than &gt; &#62;
& ampersand &amp; &#38;
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
euro &euro; &#8364;
§ section &sect; &#167;
© copyright &copy; &#169;
® registered trademark &reg; &#174;
trademark &trade; &#8482;

HTML Advanced tutorial 22 : HTML Scripts

HTML script Element
The <script> tag is used to define a client-side script, such as a JavaScript and JQuery. The script element either contains scripting statements or it points to an external script file through the src attribute. The required type attribute specifies the MIME type of the script. Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.

For Example

<script type="text/javascript">
document.write("Hello!")
</script>

The script above writes Hello! to the HTML output.

HTML noscript Element
The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn’t support client-side scripting. The noscript element can contain all the elements that you can find inside the body element of a normal HTML page.

The content inside the noscript element will only be displayed if scripts are not supported, or are disabled in the user’s browser:

For example

<script type="text/javascript">
document.write("Hello!")
</script>
<noscript>This is not inside Script!</noscript>

HTML Script Tags

Tag                   Description
<script>            Defines a client-side script
<noscript>        Defines an alternate content for users that do not support client-side scripts

HTML Advanced tutorial 23 : HTML Entities  >>
<<  HTML Advanced tutorial 21 : HTML Meta

HTML Advanced tutorial 21 : HTML Meta

Metadata is information about data. The <meta> tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.

Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata. The <meta> tag always goes inside the head element. The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services.

Keywords for Search Engines
Some search engines will use the name and content attributes of the meta element to index your pages. The following meta element defines a description of a page:

<meta name="description" content="Free Web tutorials on HTML" />

The following meta element defines keywords for a page.

<meta name="keywords" content="HTML, CSS, XML" />

The intention of the name and content attributes is to describe the content of a page.

HTML Advanced tutorial 22 : HTML Scripts  >>
<<  HTML Advanced tutorial 20 : HTML head Elements

Friday, April 20, 2012

HTML Advanced tutorial 20 : HTML head Elements

The head element is a container for all the head elements. Elements inside <head> can include scripts, instruct the browser where to find style sheets, provide meta information, and more. The following tags can be added to the head section

 <title>, <base>, <link>, <meta>, <script>, and <style>.

title Element
The <title> tag defines the title of the document. The title element is required in all HTML/XHTML documents. The title element
1). defines a title in the browser toolbar
2). provides a title for the page when it is added to favorites
3). displays a title for the page in search-engine results
For example,below is simplified HTML document.

<html>
<head>
<title>Title Here</title>
</head>
<body>
content Here.
</body>
</html>

base Element
The <base> tag specifies a default address or a default target for all links on a page. For example

<head>
<base href="http://www.yoursite.com/images/" />
<base target="_blank" />
</head>

link Element
The <link> tag defines the relationship between a document and an external resource. The <link> tag is most used to link to style sheets. For example

<head>
<link rel="stylesheet" type="text/css" href="mystylefile.css" />
</head>

style Element
The <style> tag is used to define style information for an HTML document.Inside the style element you specify how HTML elements should render in a browser:

<head>
<style type="text/css">
body {background-color:yellow}
p {color:blue}
</style>
</head>

The <meta> tag provides metadata about the HTML document.

The <script> tag is used to define a client-side script, such as a JavaScript.

HTML head Elements

Tag                Description
<head>           Defines information about the document
<title>             Defines the title of a document
<base />         Defines a default address or a default target for all links on a page
<link />           Defines the relationship between a document and an external resource
<meta />         Defines metadata about an HTML document
<script>          Defines a client-side script
<style>           Defines style information for a document

HTML Advanced tutorial 21 : HTML Meta  >>
<<  HTML Advanced tutorial 19 : HTML Styles

Wednesday, April 18, 2012

HTML Advanced tutorial 19 : HTML Styles

When a browser reads a style sheet, it will format the document according to it. There are three ways of inserting a style sheet.

  • External style sheet
  • Internal style sheet
  • Inline styles

External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the <head> section:

<head>
<link rel="stylesheet" type="text/css" href="file.css" />
</head>

Internal Style Sheet
An internal style sheet can be used if one single document has a unique style. Internal styles are defined in the <head> section of an HTML page, by using the <style> tag, like this.

<head>
<style type="text/css">
body {background-color:black;}
p {color:red;}
</style>
</head>

Inline Styles
An inline style can be used if a unique style is to be applied to one single occurrence of an element. To use inline styles, use the style attribute in the relevant tag. The style attribute can contain any CSS property. For example.

<p style="color:red;margin-left:10px;">some paragraph.</p>

HTML Style Tags

Tag           Description
<style>   Defines style information for a document
<link />   Defines the relationship between a document and an external resource

HTML Advanced tutorial 20 : HTML head Elements  >>
<<  HTML Advanced tutorial 18 : HTML Doctypes

HTML Advanced tutorial 18 : HTML Doctypes

A doctype declaration refers to the rules for the markup language, so that the browsers render the content correctly. For example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
</head>
<body>
The content of Page here.
</body>
</html>

The above HTML document contains doctype of HTML 4.01 Transitional:

Different Doctypes
The doctype declaration is not an HTML tag, it is an instruction to the web browser about what version of the markup language the page is written in. The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly. The doctype declaration should be the very first thing in an HTML document, before the <html> tag. Always add a doctype to your pages. This helps the browsers to render the page correctly!

HTML 4.01 Strict
This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements e.g font and center etc. Framesets are not allowed in this Doctype. For example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">


HTML 4.01 Transitional
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements e.g font etc. Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset
This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

HTML DOCTYPE Element

Tag                     Description
<!DOCTYPE>     Defines the document type. This declaration goes before the <html> start tag

HTML Advanced tutorial 19 : HTML Styles  >>
<<  HTML Advanced tutorial 17 : HTML Layouts

Tuesday, April 17, 2012

HTML Advanced tutorial 17 : HTML Layouts

Website Layouts
Web page layout is very important to make your website look good.  Most websites have put their content in multiple columns For Example formatted like a magazine or newspaper. Multiple columns are created by using <table> or <div> tags. Some CSS are normally also added to position elements, or to create backgrounds or colorful look for the pages.

Using Tables
The simplest way of creating layouts is by using the HTML <table> tag. The following example uses a table with 3 rows and 2 columns - the first and last row spans both columns using the colspan attribute:

<html>
<body>
<table width="450" border="0">
<tr>
<td colspan="2" style="background-color:Red;">
<h1>Header of Web Page</h1>
</td>
</tr>
<tr valign="top">
<td style="background-color:#FFD800;width:110px;text-align:top;">
<b>Menu Here</b>
</td>
<td style="background-color:#EEEEEE;height:220px;width:410px;text-align:top;">
Web content goes here</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright © 2012 yoursite.com</td>
</tr>
</table>
</body>
</html>

The HTML code above will produce the following result.

Header of Web Page

Menu Here Web content goes here
Copyright © 2012 yoursite.com

Using Div Elements
The div element is a block level element used for grouping HTML elements. The following example uses five div elements to create a multiple column layout, creating the same result as in the previous (using table tag) example.

<html>
<body>
<div id="container" style="width:500px">
<div id="header" style="background-color:Red;">
<h1 style="margin-bottom:0;">Header of Web Page</h1></div>
<div id="menu" style="background-color:#FFD800;height:200px;width:110px;float:left;">
<b>Menu</b>
</div>
<div id="content" style="background-color:#EEEEEE;height:220px;width:410px;float:left;">
Web content goes here</div>
<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
Copyright © 2011 yoursite.com</div>
</div>
</body>
</html>

The HTML code above will produce the following result.
Web content goes here

The biggest advantage of using CSS is that, if you place the CSS code in an external style sheet, your site becomes MUCH EASIER to maintain. You can change the layout of all your pages by editing one file.


HTML Layout Tags

Tag Description
<table> Defines a table
<div> Defines a section in a document

HTML Advanced tutorial 18 : HTML Doctypes  >>
<<  HTML Beginner tutorial 16 : HTML Colors

Sunday, April 15, 2012

HTML Beginner tutorial 16 : HTML Colors

Color Values
HTML colors are defined using a hexadecimal notation (HEX) for the combination of Red, Green, and Blue color values (RGB). The lowest value that can be given to one of the light sources is 0 (in HEX: 00). The highest value is 255 (in HEX: FF). HEX values are specified as 3 pairs of two-digit numbers, starting with a # sign.

Color Color HEX Color RGB
#000000 rgb(0,0,0)
#FF0000 rgb(255,0,0)
#00FF00 rgb(0,255,0)
#0000FF rgb(0,0,255)
#FFFF00 rgb(255,255,0)
#00FFFF rgb(0,255,255)
#FF00FF rgb(255,0,255)

16 Million Different Colors
The combination of Red, Green, and Blue values from 0 to 255, gives more than 16 million different colors (256 x 256 x 256). If you look at the color table, you will see the result of varying the red light from 0 to 255, while keeping the green and blue light at zero.

Gray Shades Color HEX Color RGB
#080808  rgb(8,8,8) 
#101010  rgb(16,16,16) 
#303030  rgb(48,48,48) 
#383838  rgb(56,56,56) 
#585858  rgb(88,88,88) 
#606060  rgb(96,96,96) 
#707070  rgb(112,112,112) 
#787878  rgb(120,120,120) 
#909090  rgb(144,144,144) 
#989898  rgb(152,152,152) 
#B0B0B0  rgb(176,176,176) 
#B8B8B8  rgb(184,184,184) 
#C0C0C0  rgb(192,192,192) 
#E0E0E0  rgb(224,224,224) 
#E8E8E8  rgb(232,232,232) 
#F0F0F0  rgb(240,240,240) 


Web Safe Colors
Some years ago, when computers supported max 256 different colors, a list of 216 "Web Safe Colors" was suggested as a Web standard, reserving 40 fixed system colors.
The 216 cross-browser color palette was created to ensure that all computers would display the colors correctly when running a 256 color palette. This is not important today, since most computers can display millions of different colors.


Color Names Supported by All Browsers
147 color names are defined in the HTML and CSS color specification (16 basic color names plus 130 more). The 16 basic color names are: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow.

HTML Advanced tutorial 17 : HTML Layouts  >>
<<  HTML Beginner tutorial 15 : HTML Iframes

HTML Beginner tutorial 15 : HTML Iframes

An iframe is used to display a web page within a web page. For Example, syntax for adding an iframe is

<iframe src="SITEURL"></iframe>

The SITEURL points to the location of the separate page.

Set Height and Width
The height and width attributes are used to specify the height and width of the iframe. The attribute values are specified in pixels by default, but they can also be in percent (like "90%").
For Example

<iframe src="site1.htm" width="300" height="300"></iframe>

Remove the Border
The frameborder attribute specifies whether or not to display a border around the iframe. Set the attribute value to "0" to remove the border.
For Example

<iframe src="site1.htm" frameborder="0"></iframe>

Use iframe as a Target for a Link
An iframe can be used as the target frame for a link. The target attribute of a link must refer to the name attribute of the iframe.
For Example

<iframe src="site2.htm" name="iframe_1"></iframe>
<p><a href="http://www.yoursite.com" target="iframe_a">Yahoo</a></p>

HTML iframe Tag

Tag             Description
<iframe>      Defines an inline sub window (frame)

HTML Beginner tutorial 16 : HTML Colors  >>
<<  HTML Beginner tutorial 14 : HTML Frames

Saturday, April 14, 2012

HTML Beginner tutorial 14 : HTML Frames

HTML Frames
With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others. The disadvantages of using frames are

  1. Frames are not expected to be supported in future versions of HTML
  2. Frames are difficult to use. (Printing the entire page is difficult).
  3. The web developer must keep track of more HTML documents

The HTML frameset Element
The frameset element holds one or more frame elements. Each frame element can hold a separate document. The frameset element states How many columns or rows there will be in the frameset, and how much percentage/pixels of space will occupy each of them.

The HTML frame Element
The <frame> tag defines one particular window (frame) within a frameset. For example below we have a frameset with two columns.

The first column is set to 30% of the width of the browser window. The second column is set to 70% of the width of the browser window. The document "frame_1.htm" is put into the first column, and the document "frame_2.htm" is put into the second column:

<frameset cols="30%,70%">
   <frame src="frame_1.htm" />
   <frame src="frame_2.htm" />
</frameset>

The frameset column size can also be set in pixels (cols="300,400"), and one of the columns can be set to use the remaining space, with an asterisk (cols="30%,*").


Basic Notes
If a frame has visible borders, the user can resize it by dragging the border. To prevent a user from doing this, you can add noresize="noresize" to the <frame> tag. Add the <noframes> tag for browsers that do not support frames. You cannot use the <body></body> tags together with the <frameset></frameset> tags! However, if you add a <noframes> tag containing some text for browsers that do not support frames, you will have to enclose the text in <body></body> tags! See how it is done in the first example below.


HTML Frame Tags

Tag                      Description
<frameset>           Defines a set of frames
<frame />             Defines a sub window (a frame)
<noframes>          Defines a noframe section for browsers that do not handle frames

HTML Beginner tutorial 15 : HTML Iframes  >>
<<  HTML Beginner tutorial 13 : HTML Lists

HTML Beginner tutorial 13 : HTML Lists

HTML Unordered Lists
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items are marked with bullets (typically small black circles).
For Example

<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>


How the HTML code above looks in a browser:
  • Coffee
  • Milk

HTML Ordered Lists
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items are marked with numbers.
For Example

<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>

How the HTML code above looks in a browser:
  1. Coffee
  2. Milk
HTML Definition Lists
A definition list is a list of items, with a description of each item. The <dl> tag defines a definition list. The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list). For Example

<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>

How the HTML code above looks in a browser:
Coffee
- black hot drink
Milk
- white cold drink
Inside a list item you can put text, line breaks, images, links, other lists, etc.

HTML List Tags

Tag Description
<ol> Defines an ordered list
<ul> Defines an unordered list
<li> Defines a list item
<dl> Defines a definition list
<dt> Defines an item in a definition list
<dd>  Defines a description of an item in a definition list

HTML Beginner tutorial 14 : HTML Frames  >>
<<  HTML Beginner tutorial 12 : HTML Tables

HTML Beginner tutorial 12 : HTML Tables

HTML Tables
Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other tables, etc.
For Example

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
</table>

How the HTML code above looks in a browser:

row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

HTML Tables and the Border Attribute
If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can be useful, but most of the time, we want the borders to show. To display a table with borders, specify the border attribute:

<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>

HTML Table Headers
Header information in a table are defined with the <th> tag. All major browsers display the text in the <th> element as bold and centered.

<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
</table>

How the HTML code above looks in your browser:

Header 1 Header 2 Header 3
row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3

HTML Table Tags

Tag Description
<table> Defines a table
<th> Defines a table header
<tr> Defines a table row
<td> Defines a table cell
<caption> Defines a table caption
<colgroup> Defines a group of columns in a table, for formatting
<col /> Defines attribute values for one or more columns in a table
<thead> Groups the header content in a table
<tbody> Groups the body content in a table
<tfoot> Groups the footer content in a table

HTML Beginner tutorial 13 : HTML Lists  >>
<<  HTML Beginner tutorial 11 : HTML Images

Thursday, April 12, 2012

HTML Beginner tutorial 11 HTML Images

The <img> Tag and the Src Attribute
In HTML, images are defined with the <img> tag. The <img> tag is empty, which means that it contains attributes only, and has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display.
Syntax for defining an image:

<img src="url" alt="text here"/>

The URL points to the location where the image is stored. An image named "boat.gif", located in the "images" directory on "www.yoursite.com" has the URL: http://www.yoursite.com/images/boat.gif.

The browser displays the image where the <img> tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph.

The Alt Attribute
The required alt attribute specifies an alternate text for an image, if the image cannot be displayed. The value of the alt attribute is an author-defined text.

<img src="boat.gif" alt="Big Boat" />

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Set Height and Width of an Image
The height and width attributes are used to specify the height and width of an image. The attribute values are specified in pixels by default.

<img src="img.jpg" alt="rock" width="300" height="220" />

It is a good practice to specify both the height and width attributes for an image. If these attributes are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load).

Basic Notes
If an HTML file contains ten images - eleven files are required to display the page right. Loading images takes time, so my best advice is, Use images carefully.

When a web page is loaded, it is the browser, at that moment, that actually gets the image from a web server and inserts it into the page. Therefore, make sure that the images actually stay in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon is shown if the browser cannot find the image.

HTML Beginner tutorial 12 : HTML Tables  >>
<<  HTML Beginner tutorial 10 : HTML Links

Wednesday, April 11, 2012

HTML Beginner tutorial 10 HTML Links

HTML Hyperlinks
A hyperlink is a word, group of words, or image that you can click on to jump to a new document or a new section within the current document.
When you move the cursor over a link in a Web page, the arrow will turn into a little hand. Links are specified in HTML using the <a> tag.
The <a> tag can be used in two ways:
  • To create a link to another document, by using the href attribute
  • To create a bookmark inside a document, by using the name attribute

HTML Link Syntax
The HTML code for a link is simple. It looks like this:

<a href="url">Some text here</a>

The href attribute specifies the destination of a link.
For example

<a href="http://webdesignpluscode.blogspot.com/">Visit Tutorials</a>

which will display like this: Visit Tutorials
Clicking on this hyperlink will send the user to Web design plus code's homepage.
The "Link text" doesn't have to be text. It can be an image or any other HTML element.

HTML Links - The target Attribute
The target attribute specifies where to open the linked document. The example below will open the linked document in a new browser window or a new tab.

<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

HTML Links - The name Attribute
The name attribute specifies the name of an anchor. The name attribute is used to create a bookmark inside an HTML document.
The upcoming HTML5 standard suggests using the id attribute instead of the name attribute for specifying the name of an anchor. Using the id attribute actually works also for HTML4 in all modern browsers.
Bookmarks are not displayed in any special way. They are invisible to the reader.
For example
A named anchor inside an HTML document:

<a name="tips">Useful Tips Section</a>

Create a link to the "Useful Tips Section" inside the same document:

<a href="#tips">Visit the Useful Tips Section</a>

Or, create a link to the "Useful Tips Section" from another page:

<a href="http://www.yoursite.com/html_links.htm#tips">Visit the Useful Tips Section</a>

Basic Notes
Always add a trailing slash to subfolder references. If you link like this: href="http://www.site.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.site.com/html/".
Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.

HTML Beginner tutorial 11 : HTML Images  >>
<<  HTML Beginner tutorial 9 : HTML Styles

Tuesday, April 10, 2012

HTML Beginner tutorial 9 HTML Styles

Styling HTML with CSS
CSS is used to style HTML elements.
CSS was introduced together with HTML 4, to provide a better way to style HTML elements.
CSS can be added to HTML in the following ways:
  • in Cascading Style Sheet files (CSS files)
  • in the <style> element in the HTML head section
  • in the style attribute in single HTML elements

Using the HTML Style Attribute

It is time consuming and not very practical to style HTML elements using the style attribute.
The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples.

HTML Style  - Background Color

The background-color property defines the background color for an element:
For example

html style background color
html style background color.


The background-color property makes the "old" bgcolor attribute obsolete.


HTML Style - Font, Color and Size

The font-family, color, and font-size properties defines the font, color, and size of the text in an element:
For example

html style font color size
html style font color size.


The font-family, color, and font-size properties make the old <font> tag obsolete.


HTML Style - Text Alignment

The text-align property specifies the horizontal alignment of text in an element:
For example

html style text alignment
html style text alignment.


The text-align property makes the old <center> tag obsolete.


HTML Beginner tutorial 10 : HTML Links  >>

<<  HTML Beginner tutorial 8 : HTML Fonts

HTML Beginner tutorial 8 HTML Fonts

The HTML <font> Tag Should NOT be Used
The <font> tag is deprecated in HTML 4, and removed from HTML5.
The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations.
In HTML 4, style sheets (CSS) should be used to define the layout and display properties for many HTML elements.
The example below shows how the HTML could look by using the <font> tag:

html fonts
html fonts.


The Right Way to Do It, is using Styles. Which 'll be discuss in next tutorials.

HTML Beginner tutorial 9 : HTML Styles  >>
<<  HTML Beginner tutorial 7 : HTML Text Formatting

HTML Beginner tutorial 7 HTML Text Formatting

HTML Formatting Tags

html formatting tags
html formatting tags.


HTML uses tags like <b> and <i> for formatting output, like bold or italic text.
These HTML tags are called formatting tags.
Often <strong> renders as <b>, and <em> renders as <i>.
However, there is a difference in the meaning of these tags:
<b> or <i> defines bold or italic text only.
<strong> or <em> means that you want the text to be rendered in a way that the user understands as "important".
Today, all major browsers render strong as bold and em as italics. However, if a browser one day wants to make a text highlighted with the strong feature, it might be cursive for example and not bold!

HTML Text Formatting Tags


<b>         Defines bold text

<big> Defines big text
<em> Defines emphasized text
<i>         Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text

HTML "Computer Output" Tags



<code> Defines computer code text
<kbd> Defines keyboard text
<samp> Defines sample computer code
<tt>         Defines teletype text
<var> Defines a variable
<pre> Defines preformatted text

HTML Citations, Quotations, and Definition Tags


<abbr>            Defines an abbreviation

<acronym>       Defines an acronym
<address>    Defines contact information for the author/owner of a document
<bdo>            Defines the text direction
<blockquote>    Defines a long quotation
<q>                    Defines a short quotation
<cite>            Defines a citation
<dfn>            Defines a definition term

HTML Beginner tutorial 8 : HTML Fonts  >>

<<  HTML Beginner tutorial 6 : HTML Paragraphs

HTML Beginner tutorial 6 HTML Paragraphs

HTML documents are divided into paragraphs.
HTML Paragraphs
Paragraphs are defined with the <p> tag.
For example

<p>The sun rises in the east</p>
<p>Honesty is the best policy</p>

Browsers automatically add an empty line before and after a paragraph.

Don't Forget the End Tag
Most browsers will display HTML correctly even if you forget the end tag.
For example

<p>The sun rises in the east
<p>Honesty is the best policy

The example above will work in most browsers, but don't rely on it. Forgetting the end tag can produce unexpected results or errors.
Future version of HTML will not allow you to skip end tags.

HTML Line Breaks
Use the <br /> tag if you want a line break (a new line) without starting a new paragraph:
For example

<p>This is<br />a para<br />graph with line breaks</p>

The <br /> element is an empty HTML element. It has no end tag.

<br> or <br />

In XHTML, XML, elements with no end tag (closing tag) are not allowed.
Even if <br> works in all browsers, writing <br /> instead works better in XHTML and XML applications.

HTML Output
You cannot be sure how HTML will be displayed. Large or small screens, and resized windows will create different results.
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
The browser will remove extra spaces and extra lines when the page is displayed. Any number of lines count as one line, and any number of spaces count as one space.

HTML Text Formatting  >>
<<  HTML Headings

Sunday, April 8, 2012

HTML Beginner tutorial 5 HTML Headings

Headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading.
<h6> defines the least important heading.

For example

html heading
html heading.

Headings Are Important

Use HTML headings for headings only. Don't use headings to make text BIG or bold.
Search engines use your headings to index the structure and content of your web pages.
Since users may skim your pages by its headings, it is important to use headings to show the document structure.
H1 headings should be used as main headings, followed by H2 headings, then the less important H3 headings, and so on.

HTML Lines
The <hr /> tag creates a horizontal line in an HTML page.
The hr element can be used to separate content:

For example

html line
html line.

HTML Comments

Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed.

For example

<!-- This is a comment -->

Have you ever seen a Web page and wondered "Hey! How did they do that?"

To find out, right-click in the page and select "View Source" (IE) or "View Page Source" (Firefox), or similar for other browsers. This will open a window containing the HTML code of the page.

HTML Beginner tutorial 6 : HTML Paragraphs  >>
<< HTML Beginner tutorial 4 : HTML Attributes

Friday, April 6, 2012

HTML Beginner tutorial 4 : HTML Attributes

Attributes provide additional information about HTML elements.
HTML Attributes
HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes come in name/value pairs like: name="value"

For example

HTML links are defined with the <a> tag. The link address is specified in the href attribute:

Always Quote Attribute Values

Attribute values should always be enclosed in quotes.

Double style quotes are the most common, but single style quotes are also allowed.

In some rare situations, when the attribute value itself contains quotes, it is necessary to use single quotes: name='John "ShotGun" Nelson'

Use Lowercase Attributes:

Attribute names and attribute values are case-insensitive.

However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation.

Newer versions of (X)HTML will demand lowercase attributes.

HTML Beginner tutorial 5 : HTML Headings  >>
<<  HTML Beginner tutorial 3 : HTML Elements

HTML Beginner tutorial 3 HTML Elements

HTML Elements
An HTML element is everything from the start tag to the end tag. The start tag is often called the opening tag. The end tag is often called the closing tag.

HTML Element Syntax
An HTML element starts with a start tag / opening tag
An HTML element ends with an end tag / closing tag
The element content is everything between the start and the end tag
Some HTML elements have empty content
Empty elements are closed in the start tag
Most HTML elements can have attributes

Nested HTML Elements
Most HTML elements can be nested (can contain other HTML elements).
HTML documents consist of nested HTML elements.

For example:-
html elements
html elements.

The example above contains 3 HTML elements.


The <p> element
<p>The sun rises in the East.</p>

The <p> element defines a paragraph in the HTML document.
The element has a start tag <p> and an end tag </p>.
The element content is: The sun rises in the East.

The <body> element
<body>
<p>The sun rises in the East.</p>
</body>

The <body> element defines the body of the HTML document.
The element has a start tag <body> and an end tag </body>.
The element content is another HTML element (a p element).

The <html> element
<html>


<body>
<p>The sun rises in the East.</p>
</body>


</html>

The <html> element defines the whole HTML document.
The element has a start tag <html> and an end tag </html>.
The element content is another HTML element (the body element).

Don't Forget the End Tag
Some HTML elements might display correctly even if you forget the end tag:
<p>The sun rises in the East
<p>The sun rises in the East

The example above works in most browsers, because the closing tag is considered optional.
Never rely on this. Many HTML elements will produce unexpected results and/or errors if you forget the end tag .

Empty HTML Elements
HTML elements with no content are called empty elements.

<br> is an empty element without a closing tag (the <br> tag defines a line break).

In XHTML, all elements must be closed. Adding a slash inside the start tag, like <br />, is the proper way of closing empty elements in XHTML (and XML).

HTML tags are not case sensitive: <P> means the same as <p>. Many web sites use uppercase HTML tags.

W3Schools use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in XHTML.


HTML Beginner tutorial 4 : HTML Attributes  >>
<<  HTML Beginner tutorial 2 : Basic