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

Tuesday, June 11, 2013

HTML Links


HTML uses the <a> anchor tag to create a link to another document or web page.

The Anchor Tag and the Href Attribute
An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc. The syntax of creating an anchor:

<a href="url">Text to be displayed</a>

The <a> tag is used to create an anchor to link from, the href attribute is used to tell the address of the document or page we are linking to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.

This Code
Would Display
<a href="http://www.austincc.edu/">Visit ACC!</a>
Visit ACC!

The Target Attribute
With the target attribute, you can define where the linked document will be opened. By default, the link will open in the current window. The code below will open the document in a new browser window:

<a href=http://www.austincc.edu/ target="_blank">Visit ACC!</a>

Email Links
To create an email link, you will use mailto: plus your email address. Here is a link to ACC's Help Desk:

<a href="mailto:helpdesk@austincc.edu">Email Help Desk</a>

To add a subject for the email message, you would add ?subject= after the email address. For example:

<a href="mailto:helpdesk@austincc.edu?subject=Email Assistance">Email Help Desk</a>

The Anchor Tag and the Name Attribute
The name attribute is used to create a named anchor. When using named anchors we can create links that can jump directly to a specific section on a page, instead of letting the user scroll around to find what he/she is looking for. Unlike an anchor that uses href, a named anchor doesn't change the appearance of the text (unless you set styles for that anchor) or indicate in any way that there is anything special about the text. Below is the syntax of a named anchor:

<a name="top">Text to be displayed</a>
To link directly to the top section, add a # sign and the name of the anchor to the end of a URL, like this:
This Code
Would Display
<a href="http://profdevtrain.austincc.edu/html/10links.html#top">Back to top of page </a>
A hyperlink to the top of the page from within the file 10links.html will look like this:
<a href="#top">Back to top of page </a>
Back to top of page




Back to top of page

Note: Always add a trailing slash to subfolder references. If you link like this: href="http://profdevtrain.austincc.edu/html", you will generate two HTTP requests to the server, because the server will add a slash to the address and create a new request like this: href="http://profdevtrain.austincc.edu/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. If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs.

HTML Lists


HTML provides a simple way to show unordered lists (bullet lists) or ordered lists (numbered lists).

Unordered Lists
An unordered list is a list of items marked with bullets (typically small black circles). An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

This Code
Would Display
<ul> <li>Coffee</li> <li>Milk</li> </ul>

􀂃 Coffee
􀂃 Milk


Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers. An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

This Code
Would Display
<ol> <li>Coffee</li> <li>Milk</li> </ol>

1. Coffee
2. Milk

Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.

Definition Lists
Definition lists consist of two parts: a term and a description. To mark up a definition list, you need three HTML elements; a container <dl>, a definition term <dt>, and a definition description <dd>.
This Code
Would Display
<dl> <dt>Cascading Style Sheets</dt> <dd>Style sheets are used to provide presentational suggestions for documents marked up in HTML. </dd> </dl>
Cascading Style Sheets
Style sheets are used to provide presentational suggestions for documents marked up in HTML.
Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks, images, links, other lists, etc
Try It Out
Open your text editor and type the following:

<html>
<head>
<title>My First Webpage</title>
</head>
<body bgcolor="#EDDD9E">
<h1 align="center">My First Webpage</h1>
<p>Welcome to my <strong>first</strong> webpage. I am writing this page using a text editor and plain old html.</p>
<p>By learning html, I'll be able to create web pages like a pro....<br>
which I am of course.</p>
Here's what I've learned:
<ul>
<li>How to use HTML tags</li>
<li>How to use HTML colors</li>
<li>How to create Lists</li>
</ul>
</body>
</html>
Save your page as mypage4.html and view it in your browser.

HTML Colors



Color Values
Colors are defined using a hexadecimal notation for the combination of red, green, and blue color values (RGB). The lowest value that can be given to one light source is 0 (hex #00). The highest value is 255 (hex #FF). This table shows the result of combining red, green, and blue:

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)
#C0C0C0
rgb(192,192,192)
#FFFFFF
rgb(255,255,255)




Color Names
A collection of color names is supported by most browsers. To view a table of color names that are supported by most browsers visit this web page:

http://profdevtrain.austincc.edu/html/color_names.htm

Note: Only 16 color names are supported by the W3C HTML 4.0 standard (aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow). For all other colors you should use the Color HEX value.

Color HEX
Color Name
#F0F8FF
AliceBlue
#FAEBD7
AntiqueWhite
#7FFFD4
Aquamarine
#000000
Black
#0000FF
Blue
#8A2BE2
BlueViolet
#A52A2A
Brown

Web Safe Colors
A few years ago, when most computers supported only 256 different colors, a list of 216 Web Safe Colors was suggested as a Web standard. The reason for this was that the Microsoft and Mac operating system used 40 different "reserved" fixed system colors (about 20 each). This 216 cross platform web safe color palette was originally created to ensure that all computers would display all colors correctly when running a 256 color palette. 

16 Million Different Colors
The combination of Red, Green and Blue values from 0 to 255 gives a total of more than 16 million different colors to play with (256 x 256 x 256). Most modern monitors are capable of displaying at least 16,384 different colors.

HTML Fonts and HTML Backgrounds


HTML Fonts
The <font> tag in HTML is deprecated. The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations. In future versions of HTML, style sheets (CSS) will be used to define the layout and display properties of HTML elements.

The <font> Tag Should NOT be used.

HTML Backgrounds
Backgrounds
The <body> tag has two attributes where you can specify backgrounds. The background can be a color or an image.

Bgcolor
The bgcolor attribute specifies a background-color for an HTML page. The value of this attribute can be a hexadecimal number, an RGB value, or a color name:

<body bgcolor="#000000"> <body bgcolor="rgb(0,0,0)"> <body bgcolor="black">

The lines above all set the background-color to black.

Background
The background attribute can also specify a background-image for an HTML page. The value of this attribute is the URL of the image you want to use. If the image is smaller than the browser window, the image will repeat itself until it fills the entire browser window.

<body background="clouds.gif"> <body background = "http://profdevtrain.austincc.edu/html/graphics/clouds.gif">

The URL can be relative (as in the first line above) or absolute (as in the second line above).
If you want to use a background image, you should keep in mind:

  • Will the background image increase the loading time too much?
  • Will the background image look good with other images on the page?
  • Will the background image look good with the text colors on the page?
  • Will the background image look good when it is repeated on the page?
  • Will the background image take away the focus from the text?


Note: The bgcolor, background, and the text attributes in the <body> tag are deprecated in the latest versions of HTML (HTML 4 and XHTML). The World Wide Web Consortium (W3C) has removed these attributes from its recommendations. Style sheets (CSS) should be used instead (to define the layout and display properties of HTML elements).

Try It Out!
Open your text editor and type the following text:
<html>
<head>
<title>My First Webpage</title>
</head>
<body background="http://profdevtrain.austincc.edu/html/graphics/clouds.gif" bgcolor="#EDDD9E">
<h1 align="center">My First Webpage</h1> 

<p>Welcome to my <strong>first</strong> webpage. I am writing this page using a text editor and plain old html.</p> 

<p>By learning html, I'll be able to create webpages like a <del>beginner</del> pro....<br> 

which I am of course.</p> 

</body> 

</html>

Save your page as mypage3.html and view it in your browser. 
Notice we gave our page a background color as well as a background image. If for some reason the web page is unable to find the picture, it will display our background color.

Basic HTML Tags



The most important tags in HTML are tags that define headings, paragraphs and line breaks.

Basic HTML Tags Tag
Description
<html>
Defines an HTML document
<body>
Defines the document's body
<h1> to <h6>
Defines header 1 to header 6
<p>
Defines a paragraph
<br>
Inserts a single line break
<hr>
Defines a horizontal rule
<!-->
Defines a comment

Headings

Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading while <h6> defines the smallest.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6> This is a heading</h6>

HTML automatically adds an extra blank line before and after a heading. A useful heading attribute is align.

<h5 align="left">I can align headings </h5>
<h5 align="center">This is a centered heading </h5>
<h5 align="right">This is a heading aligned to the right </h5>

Paragraphs

Paragraphs are defined with the <p> tag. Think of a paragraph as a block of text. You can use the align attribute with a paragraph tag as well.
<p align="left">This is a paragraph</p>
<p align="center">this is another paragraph</p>

Important: You must indicate paragraphs with <p> elements. A browser ignores any indentations or blank lines in the source text. Without <p> elements, the document becomes one large paragraph. HTML automatically adds an extra blank line before and after a paragraph.

Line Breaks

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

The <br> tag has no closing tag.

Horizontal Rule

The <hr> element is used for horizontal rules that act as dividers between sections, like this:

<hr width="50%" align="center">

Comments in HTML

The comment tag is used to insert a comment in the HTML source code. A comment can be placed anywhere in the document and the browser will ignore everything inside the brackets. You can use comments to write notes to yourself, or write a helpful message to someone looking at your source code.
<p> This html comment would <!-- This is a comment --> be displayed like this.</p>

Notice you don't see the text between the tags <!-- and -->. If you look at the source code, you would see the comment. To view the source code for this page, in your browser window, select View and then select Source.
Note: You need an exclamation point after the opening bracket <!-- but not before the closing bracket -->.
HTML automatically adds an extra blank line before and after some elements, like before and after a paragraph, and before and after a heading. If you want to insert blank lines into your document, use the <br> tag.

Try It Out!

Open your text editor and type the following text:
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1 align="center">My First Webpage</h1>
<p>Welcome to my first web page. I am writing this page using a text editor and plain old html.</p>
<p>By learning html, I'll be able to create web pages like a pro....<br>
which I am of course.</p>
</body>
</html>

Save the page as mypage2.html. Open the file in your Internet browser. To view how the page should look, visit this web page: http://profdevtrain.austincc.edu/html/mypage2.html

Other HTML Tags
As mentioned before, there are logical styles that describe what the text should be and physical styles which actually provide physical formatting. It is recommended to use the logical tags and use style sheets to style the text in those tags.
Logical Tags
Tag
Description
<abbr>
Defines an abbreviation
<acronym>
Defines an acronym
<address>
Defines an address element
<cite>
Defines a citation
<code>
Defines computer code text
<blockquote>
Defines a long quotation
<del>
Defines text
<dfn>
Defines a definition term
<em>
Defines emphasized text
<ins>
Defines inserted text
<kbd>
Defines keyboard text
<pre>
Defines preformatted text
<q>
Defines a short quotation
<samp>
Defines sample computer code
<strong>
Defines strong text
<var>
Defines a variable

Physical Tags
Tag
Description
<b>
Defines bold text
<big>
Defines big text
<i>
Defines italic text
<small>
Defines small text
<sup>
Defines superscripted text
<sub>
Defines subscripted text
<tt>
Defines teletype text
<u>
Deprecated. Use styles instead
Character tags like <strong> and <em> produce the same physical display as <b> and <i> but are more uniformly supported across different browsers.

Some Examples:
The following paragraph uses the <blockquote> tag. In the previous sentence, the blockquote tag is enclosed in the <samp> Sample tag.

We the people of the United States, in order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defense, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.

Although most browsers render blockquoted text by indenting it, that's not specifically what it's designed to do. It's conceivable that some future browser may render blockquoted text in some other way. However, for the time being, it is perfectly safe to indent blocks of text with the <blockquote>.

Example:
<abbr title="World Wide Web">WWW</abbr> 

Result :
WWW