You are here: Re: CSS - A color within H2 « HTML « IT news, forums, messages
Re: CSS - A color within H2

Posted by Jukka K. Korpela on 04/07/07 12:39

Scripsit Simon Harris:

> I have my A tags (links) set to green when they are on the body or
> table cells. This works Ok.

No it doesn't. People have to guess what green means, instead of immediately
noticing nice tasty blue links with a delicious underline.

> I have a background color of orange on my H2 tags, I want to use
> black for A tags in this case.

As a rule of thumb, keep links out of headings.

> h2 a {
> color: #000000;
> }

It fails to have the desired effect because another CSS rule overrides its
effect, by its specificity. More seriously, if it worked, it would remove
the vital distinction between visited and unvisited (and hovered) links as
well as set color against an unspecified background.

If you really, really needed to set link colors inside headings, you should
do something like

h2 a:link { color: blue; background: white; }
h2 a:visited { color: magenta; background: white; }
h2 a:link:hover, h2 a:visited:hover { color: red; background: white; }

(and this is a _simple_ version). If you want to use the same background as
for the h2 element in general, you need to think hard to find colors are
easily readable against that background, differ from each other
sufficiently, and are close enough to common default link colors to give a
hint.

> Have copied my entire CSS for reference, below.

How long did you actually read this group before posting? There are _daily_
flames about posting bulks of code and not a URL. How did you miss that
advice?

> body {
> background-color : #FFFFCC;
> font: 8pt/10pt verdana;
> margin: 0px;
> text-align:center;
> }

Sorry, you should rewrite your style sheet from scratch. That's far easier
and faster than fixing it.

The above already suggests that it went on the wrong track. For example,
setting font size to 8pt is so wrong that it should be criminal (and might
be a criminal violation of accessibility laws in some countries).

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация