Define colors for individual links on the HTML page

The method described as link, vlink, alink is for setting overall link colors for the page.

However, we might want one or more links to have different colors than the rest of the page.

There are two methods for doing this:

  • Placing font tags between the <a href> and the </a> tag. This method will work on all browsers except Microsoft Internet Explorer 3 (MSIE 3).

  • Using a style setting in the <a> tag. This method works on MSIE 3 and newer browsers.

The first technique would look like this:

Click <a href = "http://anybodycanmaster-computer-network.blogspot.com"><font
color="FF00CC"
> here</font></a> to go to this website.



Note:
If is important that both <font> and the </font> tags are between the <a href> and </a> tags.

The second technique would like this:

Click <a href = "http://anybodycanmaster-computer-network.blogspot.com"
style="color : rgb(0,255,0)"> here</a> to go to this website.


Note:

The RBG numbers indicates amounts of red , green and blue using values between 0 and 255.

Now, since neither of the two methods covers all browsers, we need to use both techniques at once.

This example works on all browsers:


Click <a href = "http://anybodycanmaster-computer-network.blogspot.com"
style="color : rgb(0,255,0)"
><font color ="FF00CC"> here</font></a> to go to this website.

The last example is interesting. Not only because it will work on all the browsers. But even more because it shows a general to make the pages browser safe. Since browsers simply leave out information that is not understood, we can work around browser differences by simply adding different settings for multiple browsers.

Colors on Text Links in HTML

There are few settings that can be useful for controlling the colors of text links.

This page will teach us how to:

  • Define colors for all links on the page.
  • Define colors for individual links on the page.

Define colors for all links on the page

The general color of text links is specified in the <body> tag, like in the example below:


<body link ="#C0C0C0" vlink = "808080" alink = "FF0000">


  • Link - standard link - to a page the visitor hasn't been to yet. (standard color is blue - #0000FF).

  • vLink - visited link - to a page the visitor has been to before. (standard color is purple - #800080)

  • aLink - active link - the color of the link when the mouse is on it. (standard color is red - #FF0000).

How to make a Link in HTML

The tags used to produce links are the <a> and </a>. The <a> tells where the link should start and the </a> indicates where the link ends. Everything between these two will work as a link. The target of the link is added to the <a> tag using the href = "http://www.anybodycanmaster-computer-network.blogspot.com/" setting.

There example below shows how to make the word here work as a link to yahoo.

Click <a href="http://www.yahoo.com">here</a> to go to yahoo.


We simply:

  • Specify the target in the <a href = " ">.

  • Then add the text that should work as a link.

  • Finally add an </a> tag to indicate where the link ends.

HTML Links

Links are the most fundamental part of the world wide web. It is the links that tie it all together.

There are three different kinds of links we can have on our website:
  • Links to anchors on the current page (Internal Links).
  • Links to other pages within the current site (Local Links).
  • Links to pages outside the current site (Global Links).

It is possible to make texts and images work as links. With a little creativity other object, such as push buttons or even drop-down menus can work as links as well. This section will cover the usual links: Text and Images.

Wrap Text Around Images in HTML

In addition to the vertical alignments, images can also be aligned horizontally. To do this, add align ="left" or align = "right" or align = "center" to the <img> tag.

align = "left"



align = "right"



align = "center"



Another way to obtain the same effect would be to enter the image and text in an invisible table. Entering text in one column and the image in another would create a similar effect.

Alignment of Images in HTML

We can align images according to the text around it, using the following alignments:


  • Default aligns the image using default settings of the Web browser. Same as baseline.

  • Left aligns the image in the left margin and wraps the text that follows the image.

  • Right aligns the image in the right margin and wraps the text that precedes the image.

  • Top aligns the top of the image with the surrounding text.

  • TextTop aligns the top of the image with the top of the tallest text in the line.

  • Middle aligns the middle of the image with the surrounding text.

  • Absmiddle aligns the image with the middle of the current line.

  • Baseline aligns the image with the baseline of the current line.

  • Bottom aligns the bottom of the image with the surrounding text.

  • Absbottom aligns the image with the bottom of the current line.

  • Center aligns the center of the image with the surrounding text.

Below we can see examples of the different vertical alignments we can make for an image.

<img src="rainbow.gif" align = "texttop">


<img src="rainbow.gif" align = "middle">


<img src="rainbow.gif" align = "absmiddle">


<img src="rainbow.gif" align = "bottom">


<img src="rainbow.gif" align = "absbottom">


<img src="rainbow.gif" align = "baseline">

Spacing Around Images in HTML

We can easily add space over and under our images with the Vspace attribute. In a similar way we can add space to the left and right of the image using the Hspace attribute. Below is an example using these attributes:

<img src="rainbow.gif" Hspace = "30"> Vspace = "10"


As we see these settings allow us to add spacing around our image. Unfortunately they also force us to add the same spacing to each side of the image (over and under - or left and right). The workaround for this, if we only want spacing on one side of the image is to use a 1 x 1 pixel transparent gif image. If, for example, we wanted a 10 pixel spacing to the left of our image we could use the transparent image (pixel.gif) this way:

<img src="pixel.gif" width = "10" height = "1"><img src = "rainbow.gif">


The 1 x 1 pixel transparent gif image is simply stretched to whatever size we want the spacing to have. This 1 x 1 pixel "cowboy-trick" is probably one of the most widely used workarounds on the entire net. The reasons are obvious: It works on all browsers and it gives us complete pixel precision in our design!

About Me

My photo
Vision :- "To be a reputed institution of Smart People who Add Value Across Generation". Mission :- We are dedicated to Spreading Literacy in Society and Helping People choose Value for Money Products for Better Living.We are also adding health awareness and wellness to the society of India." We are distributor and promotors of India's Largest IT products Direct Selling Company with a reach of more than 250 cities nationwide. We have a strong internet R&D base to bring out cost effective and Quality products.