Friday, April 27, 2012

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