Pieter888
Pieter888

Reputation: 5012

Change text color on mouse over using the style tag

Using CSS it's easy to apply a custom color to a link when you hover over it using:

.myId:hover{
    color:green;
}

But what about the style tag? It is possible to do something along the lines of:

<a style="*insert nifty markup here to change color on hover*" href="somewhere.html">text</a>

Or is changing the hover color only possible trough the first method (using only html/css, no javascript allowed).

Upvotes: 4

Views: 4092

Answers (3)

Kyle
Kyle

Reputation: 67244

AFAIK you can only use either the <style> tag in the <head> section, or an external stylesheet.

The first suggestion is the best. Inline styles are the most specific and can never be ovridden, also it's difficult to find them when editing. It's best to keep all CSS either in the head of an external stylsheet :) (imo)

Upvotes: 1

David Houde
David Houde

Reputation: 4778

You cannot and should not do this. Give it a class or id, and a stylesheet.

Upvotes: 6

Marko
Marko

Reputation: 72230

Nope, I don't think you can alter states or add selectors via the style tag.

Upvotes: 2

Related Questions