CSS font stacks, media style sheets & web standards

Your banner ad here

WestNIC provides reliable web hosting services

25% off cpanel web hosting and reseller hosting deals. Promo: codestyle25off

Site navigation below

This answer is part of the Code Style premium content package. You must have a premium content subscription to log in and view the full answer to this question.

Use the premium content subscription form below for full access to all premium content FAQs, or the FAQ by email option for the answer to this FAQ only.

A: First, it is not a good idea to change link colours on a page. Users tend to identify links with a standard, fixed colour and may ignore text with a different, varying colour. People with visual impairment may also find it difficult to read the text, especially if it is the same as the custom background colour they have chosen. It is therefore important to ensure the background colour is set with the foreground colour.

The example code below creates an array of 4 named colours, a delay of 5000 milliseconds and uses the setTimeout() method to trigger the colour change. A reference to the link is obtained by assigning an id attribute to the anchor and using the DOM1 getElementById() method. The existence of the getElementById() method is checked before setting the style.color and style.background properties of the element.

premium content omitted

Premium Content: Follow this link for subscription information Get full access to all FAQs, subscribe now for $40
How can I make a link whose colour changes every 5 seconds?

Get the answer to this FAQ by email Get the full answer to this FAQ by email for $2.99
within 24 hours of clearance by PayPal.

Premium content subscription

You must make a subscription payment to access areas flagged premium content. Use the form below to create an account via PayPal.

Premium Content subscription @ $40.00 USD

Subscribe now:

Your security

The PayPal service allows you to pay securely and independently in your own currency. Payments are billed to Metacentric Internet Limited. We never handle your credit card details.

Why pay for premium content?

The Code Style site has accumulated 8 years' worth of answers to the most common Web development questions. Answers are written in clear English with examples and links to other Web resources. Your subscription provides full answers to all premium content questions listed below and other FAQ sections, plus:

Javascript FAQ: premium questions

Javascript browser FAQ: premium questions

Javascript "how to" FAQ: premium questions

Document Object Model FAQ: premium questions

Drop-down menus FAQ: premium questions

DOM menu customisation FAQ: premium questions

Add this page to your chosen social bookmarking service

Style warning - please read

Home · CSS · Java · Javascript · HTML · Help · Log