Setting colour for <a name="1"> anchor links

Not open for further replies.

Big D

New Member
Can anyone tell me what code to use in my css stylesheet so that I can set the colour of my anchor links to the same colour as the page text colour?

The word work, for example, is showing up as my general link colour

<a name="38">work</a>

whereas I need it to blend with the surrounding text.

I have tried a few combinations like {color: #666666}

but haven't cracked it yet.

Any ideas?


New Member
<a name="38" style='color:#666666;'>work</a>
or you can give it an id and use that to set the style in your CSS
<a name='38' id='a38'>name</a>
/*and in your css file...*/
#a38 a{color:#666666;}

Big D

New Member
Louie, thanks for that, but I have 1000s of pages on the site and would like to set the <a name=""> colour universally on the stylesheet.

Is there not a simple piece of code which can set the colour for all the name tags on the site?

Big D


New Member
yes there is but without a link to view the source of the page I can not help.

You need to look for the container id and set the a style based on that.
Don't know if you follow me but give us a link and we might be able to help you.


New Member
it looks the same color to me as the rest of the text.
anyway try setting the a color based on the container div "col1"
.col1 a:link, .col1 a:visited{color:#666666; font-weight:bold;}
.col1 a:hover{color:#99000;}

Big D

New Member

The only difficulty I see with that is that I only want to change the colour of the <a name> links in the centre column, not the <a href> links - on some pages there will be both.

I agree re link colour but I've found it difficult to get a green colour which works across the board and stands out against the grey without looking gaudy.

I bet you wish you hadn't replied now!


New Member
sorry for saying that to you, but that's because of bad design implementation.
If you add those links between <span class='some_class'>anchor</span> you will get what you want.
Another way is to add the style on the fly using preg_replace or str_replace (php) to those links only.
There are many way to skin a cat but that will depend on your capabilities...

BTW - I am not sorry for getting involved into this at all - I can pull-out anytime if I choose to... :)


New Member
try this:

//your variable
$desc = $row['desc'];//db field name
$desc = str_replace("<a name","<a style='color:#666666; background-color:#990000;font-weight:bold;' name",$desc);
echo $desc;
I'm probably doing something really thick here like not putting the code you sent in certain tags or rewording part but, no, it didn't work

@CHARSET "ISO-8859-1";
body {
font-family: Arial;
color: #666666;
//your variable
$desc = $row['desc'];//db field name

$desc = str_replace("<a name","<a style='color:#666666; background-color:#990000;font-weight:bold;' name",$desc);

echo $desc;
h1,h2,h3,h4 {color: #cc9933; margin: 0; padding:0;}
p { padding: .2em; text-align: justify; font: arial; line-height: 125%;}
a { color: #336633; font: arial; text-decoration: none;}
a:visited {color: #cc9933; text-decoration: none;}
hr { border: none; background:#000; padding:0; height: 1px;}
/* repeated code per header */
#title {
width: 160px; height: 50px;
background-image: url(ireland-logo.jpg);
background-repeat: no-repeat;
background-position: 20px 10px;
#navbar {
border: double #3D5229 4px;
padding-top: 8px;
padding-bottom: 8px;
#navbar img { padding:0; margin:0; display:none; }
#navbar ul li a { color: #FFF; }
#navbar ul li a:active { color: #FFF; }
#navbar ul li a:hover { background:#3D5229; }
#header ul li { background:#5E7F3F; font-weight:bold; color:#fff; }
#mainmenu { background-color:#F4F4F4;}
#mainmenu { font-size: 11px;}
#mainmenu ul li a { color: #000;; }
#mainmenu ul li a:hover { background-color:#3D5229; color:#FFF; }
#mainmenu ul li { background:#5E7F3F; font-weight:bold; color:#fff; }
#mainmenu ul li a.last { margin-right: 0; }
#mainmenu ul li a.reallast { margin-left: 10px; margin-right: 0; }
.col1 ul
margin-left: 50px;
padding-left: 0;
list-style: none;
.col1 li
padding-left: 20px;
background-image: url(arrow.gif);
background-repeat: no-repeat;
background-position: 0 .5em;
line-height: 1.4em;

/* 3 Column settings */
.threecol {
background:#FFF; /* right column background colour */
.threecol .colmid {
background:#FFF; /* center column background colour */
padding-top: 20px;
.threecol .colleft {
background:#FFF; /* left column background colour */

#footer { background-color: #8BA870; color: #FFF; font-size:80%; padding:1em 2%; border-top:1px solid #ccc; }
#footer a { font-weight: bold; color: #FFF; } { width: 100%; text-align: center; padding: 0 0 0 0; }
div.searchGoogle { width: 100%; text-align: center; margin: 0 0 0 0; }
div.rssFeed { background-color: #FEFEFE; padding: 0.4em;}
div.rssFeed p { font: 0.8em/1.2em verdana; padding:0; text-align: left; }
div.rssFeed p.rssTitle { background:#8BA870;color:#FFFFFF; padding:0.2em; }
div.rssFeed p.title { font: 0.9em/1.4em verdana; margin:0; padding:0.3em; background: #EFEFEF; }
div.rssFeed p.desc { font: 0.8em/1.3em verdana; margin:0; padding:0.4em 0.4em 0.4em 1em; }
div.rssFeed { font: 0.9em/1.4em verdana; margin:0; padding:0 0 0.4em 0; text-align: right; }
div.rssFeed p.others { font: 0.9em/1.4em verdana; margin:0; padding:0.4em 0.4em 0.4em 1em; text-align: left; }
div.rssFeed p a { text-decoration: none; color: #000000; font: 1em/1.4em Verdana; }
div.rssFeed a { text-decoration: none; color: #000000; font: 0.8em/1.2em Verdana; }
div.rssFeed p.others a { text-decoration: none; color: #000000; font: 0.8em/1.2em Verdana; }
you don't put that code in the css file as it's php code.
You need to add it to the page itself where the data is retrieve from the database itself.
Ah, right - I will try putting it in the header.php file to see if that works across the site.

Many thanks for your help on this one!:)
I'm setting up the code for the pages myself

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL=""]"><html[/URL] xmlns="[url=]XHTML namespace[/url]">
 <title>Celtic Literature</title>
 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /><meta name="keywords" content="irish celtic literature books history ireland">
<meta name="description" content="Celtic Literature lost and preserved, from An Illustrated History of Ireland, 1868, by Sister Mary Frances Clare (Margaret Anne Cusack), The Nun of Kenmare, with illustrations by Henry Doyle">
<link href="[URL][/URL]" rel="stylesheet" type="text/css" /><link href="[URL][/URL]" rel="stylesheet" type="text/css" /><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<p style="text-align:center;"><img src="Irish-History.jpg" alt="Irish History emblem"></p>
<p style="text-align:center;"><strong>CHAPTER I.</strong></p>
<h3 style="text-align:center;">Celtic Literature</h3> 
<p style="text-align:center;">From <a href="[url=]History of Ireland[/url]" />An Illustrated History of Ireland</a> by Margaret Anne Cusack</p>
<p style="text-align:center;"><a href="[url=]Irish Emigration Statistics[/url]" />&laquo; Emigration Statistics</a> | <a href="[url=]History of Ireland - Contents[/url]" />Contents</a> | <a href="[URL][/URL]" />Materials for Irish History &raquo;</a></p>
<p>Celtic Literature&mdash;Antiquity of our Annals&mdash;Moore&mdash;How we should estimate Tradition&mdash;The Materials for Irish History&mdash;List of the Lost Books&mdash;The Cuilmenn&mdash;The Saltair of Tara, &amp;c.&mdash;The Saltair of Cashel&mdash;Important MSS. preserved in Trinity College&mdash;By the Royal Irish Academy&mdash;In Belgium.</p>
<p><img src="Letter-T-Shamrocks.jpg" alt="Letter T" align="left" hspace="5"><br />
<br />
HE study of Celtic literature, which is daily becoming of increased importance to the philologist, has proved a matter of no inconsiderable value to the Irish historian. When Moore visited O'Curry, and found him surrounded with such works as the <i>Books of Ballymote and Lecain</i>, the <i>Speckled Book</i>, the <i>Annals of the Four Masters</i>, and other treasures of Gaedhilic lore, he turned to Dr. Petrie, and exclaimed: &quot;These large tomes could not have been written by fools or for any foolish purpose. I never knew anything about them before, and I had no right to have undertaken the <i>History of Ireland.&quot;</i> His publishers, who had less scruples, or more utilitarian views, insisted on the comple  tion of his task. Whatever their motives may have been, we may thank them for the result. Though Moore's history cannot now be quoted as an authority, it accomplished its <a name="38">work</a> for the time, and promoted an interest in the history of one of the most ancient nations of the human race.</p>
<p>There are two sources from whence the early history of a nation may be safely derived: the first internal&mdash;the self-consciousness of the individual; the second external&mdash;the knowledge of its existence by others&mdash;the <i>ego sum</i> and the <i>tu es</i>; and our acceptance of the statements of each on <i>matters of fact</i>, should depend on their mutual agreement.</p>
<p>The first question, then, for the historian should be, What accounts does this nation give of its early history? the second, What account of this nation's early history can be obtained <i>ab extra</i>? By stating and comparing these accounts with such critical acumen as the writer may be able to command, we may obtain something approaching to authentic history. The history of ancient peoples must have its basis on tradition. The name tradition unfortunately gives an <i>&agrave; priori</i> impression of untruthfulness, and hence the difficulty of accepting tradition as an element of truth in historic research. But tradition is not necessarily either a pure myth or a falsified account of facts. The traditions of a nation are like an aged man's recollection of his childhood, and should be treated as such. If we would know his early history, we let him tell the tale in his own fashion. It may be he will dwell long upon occurrences interesting to himself, and apart from the object of our inquiries; it may be he will equivocate unintentionally if cross-examined in detail; but truth will underlie his garrulous story, and by patient analysis we may sift it out, and obtain the information we desire.</p>
<p>A nation does not begin to write its history at the first moment of its existence. Hence, when the chronicle is compiled which first embodies its story, tradition forms the basis. None but an inspired historian can commence <i>In principio</i>. The nation has passed through several generations, the people already begin to talk of &quot;old times;&quot; but as they are nearer these &quot; old times &quot; by some thousands of years than we are, they are only burdened with the traditions of a few centuries at the most; and unless there is evidence of a wilful object or intent to falsify their chronicles, we may in the main depend on their accuracy. Let us see how this applies to Gaedhilic history. The labours of the late lamented Eugene O'Curry have made this an easy task. He took to his work a critical acumen not often attained by the self-educated, and a noble patriotism not <a name="39">often</a> maintained by the gifted scions of a country whose people and whose literature have been alike trodden down and despised for centuries. The result of his researches is embodied in a work <a href="#1">[1]</a> which should be in the hands of every student of Irish history, and of every Irishman who can afford to procure it. This volume proves that the <i>early</i> history of Ireland has yet to be written; that it should be a work of magnitude, and undertaken by one gifted with special qualifications, which the present writer certainly does not possess; and that it will probably require many years of patient labour from the &quot;host of Erinn's sons,&quot; before the necessary materials for such a history can be prepared.</p>
<p style="text-align:center;"><a href="[url=]Irish Emigration Statistics[/url]" />&laquo; Emigration Statistics</a> | <a href="[url=]History of Ireland - Contents[/url]" />Contents</a> | <a href="[URL][/URL]" />Materials for Irish History &raquo;</a></p>
<hr />
<p><a name="1">[1]</a> <i>Work</i>.&mdash;<i>Lectures on the MS. Materials of Ancient Irish History</i>. This work was published at the sole cost of the Catholic University of Ireland, and will be an eternal monument of their patriotism and devotion to literature. A chair of Irish History and Archaeology was also founded at the very commencement of the University; and yet the &quot;Queen's Colleges&quot; are discarding this study, while an English professor in Oxford is warmly advocating its promotion. Is the value of a chair to be estimated by the number of pupils who surround it, or by the contributions to science of the professor who holds it?</p>
Sorry, Louie, I'm not sure which code you mean

In creating a new page I just use doctype code etc from old pages and change the contents

I am only aware of the following components to create my pages:


Apologies for my density on this
you are probably using a package like Joomla to create the pages for you which in this case will make it difficult for us to help you with the problem.
ok, Louie, not to worry - it's annoying but not critical at this stage. I will pursue it again later.

thank you for your assistance
why can't you set the style manually
<a name='name' style='color:#666666; background-color:#990000; font-weight:bold;'>name</a>
when you are writing the article.
One problem with that is that if the text colour for the site changes over time then I would need to go back to the book and replace the colour code - and I would need to do the same for all the other books with name tags in.
Not open for further replies.
Award-winning Mac antivirus and Internet security software