Showing posts with label HTML Beginner. Show all posts
Showing posts with label HTML Beginner. Show all posts

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

HTML Beginner tutorial 2 Basic of HTML

HTML Headings
HTML headings are defined with the <h1> to <h6> tags.

For example:-

html headings
html headings.

HTML Paragraphs
HTML paragraphs are defined with the <p> tag.

For example:-

html paragraph
html paragraph.


HTML Links
HTML links are defined with the <a> tag.

For example:-

html link
html link.


Note: The link address is specified in the href attribute.


HTML Images
HTML images are defined with the <img> tag.

For example:-

html image
html image.


Note: The name and the size of the image are provided as attributes.

HTML Beginner tutorial 3 : HTML Elements  >>
<<  HTML Beginner tutorial 1 : Introduction

Wednesday, August 10, 2011

HTML Beginner Tutorial 1 Introduction to HTML

HTML is used to describe web pages. It stands for Hyper Text Markup Language. It is a markup language, not a programming language. It uses markup ( tags e.g  <html> and </html> ) to describe web contents. Each markup tag has its opening and closing, i.e it comes in pairs. For example <html> is starting markup tag and </html> is ending markup tag.

Web pages are also called html documents, because these consists of html tags. Html documents consists of html tags and plain text to describe it as a whole web page.

Web Browsers are places where we see html documents ( web pages ). Web Browsers interpret these html tags and show contents of pages.

html documents consists of following parts.
Simple HTML Document
Simple html document.
Paste the above code in notepad and save it as filename.html ( e.g index.html ).
it will be save as a webpage, now open this page and see the web content. To change its content open it in notepad or in any text editor and change the plain text and click "Save" in file menu, to see changes.
In above code :
  • Everything in between <html> and </html> describe the web content. 
  • Everything between <head> and </head> describe the web header. 
  • Everything between <title> and </title> describe the title of the page ( for example 'welcome to my page' ). 
  • Everything between <body> and </body> describe the visible content on web page. Everything between <h> and </h> describe the Heading. 
  • Everything between <p> and </p> describe the paragraph.