upsergeEnesee
New Member
I'm fairly new to programming, so I apologize for what is, I'm sure, a relatively simple question.I'm looking for an efficient way to make the link color within the \[code\]<a>\[/code\] tags of each html page different (i.e. one page will have green links, while another will have blue links) without having to add \[code\]class="green"\[/code\] or \[code\]class="blue"\[/code\] to every single \[code\]<a>\[/code\] tag.I understand that I could have separate css documents for each page, but I'd like to keep the whole site on one css page, so I don't have to update each style sheet separately when I want to make overarching changes.Is there a way of defining the style rules in the \[code\]<a>\[/code\] tags in relation to the class of a higher tag? For example, would it be possible to say\[code\]<body><div class="page1content"><p>text here <a href="http://stackoverflow.com/questions/15628032/someurl.com"> link here </a> more text <a href="http://stackoverflow.com/questions/15628032/secondurl.com"> second link</p> </div><div class="footer"><p>even more text<a href="http://stackoverflow.com/questions/15628032/thirdurl.com"></a></p></div></body>\[/code\]and then define the first two \[code\]<a>\[/code\] tags (without affecting the third \[code\]<a>\[/code\] tag) in relation to the \[code\]<div class="page1content">\[/code\]? I'd then replace that with \[code\]<div class="page2">\[/code\], \[code\]<div class="page3">\[/code\], etc. for each page.The only other thing I could think of was to try using JavaScript, which I'm not too familiar.I tried inserting\[code\]<script type="text/javascript">var myObj = document.getElementsByTagName("a");myObj.style.color="green";</script>\[/code\]into a given page, hoping that it would make the text color within all the \[code\]<a>\[/code\] tags on that page green, but it didn't seem to work.By way of comparison, I also tested my JavaScript by changing the "a" to a "p" as follows:\[code\]<script type="text/javascript">var myObj = document.getElementsByTagName("p");myObj.style.color="green";</script>\[/code\]in the hope that this would turn all my \[code\]<p>\[/code\] text green, but that didn't work either, so clearly I miscoded the JavaScript, for starters. Any thoughts on how to alter multiple \[code\]<a>\[/code\] tags on a given page at once (without putting a class inside the tag) would be greatly appreciated. Thanks!