Solved

Overriding CSS styles for specific links on a particular page

Posted on 2009-04-09
8
714 Views
Last Modified: 2012-05-06
I am building a web site using Dreamweaver CS3. I am using a grid of small photos as a navigational tool on a few pages. For aesthetic reasons, I don't want any link highlighting on these linked photos -- no link, visited, active or hover highlighting. I have a fade-in and fade-out behavior assigned to each linked photo and that's the only thing I want to change visually when the mouse passes over the images.

The link highlighting is controlled globally by a CSS style sheet. Is there a way to override the CSS link styles and apply no link styles to specific links on a specific page, while leaving the other links on that page unchanged (i.e., controlled by the CSS style sheet)?
0
Comment
Question by:don0don
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 11

Expert Comment

by:level9wizard
ID: 24109285
You can manage that link with it's own css class. For example

/*  THE CSS */
<a href="page.html" class="custom"><img src="" alt="" /></a>


<!-- THE HTML -->
a.cusotm
{
     text-decoration: none;
     border: none;
}
0
 
LVL 11

Accepted Solution

by:
level9wizard earned 125 total points
ID: 24109320
Hah, had that backwards and typo'd - sorry about that. Here's a full working example.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>test </title>
 
	<style type="text/css">
	a.custom
	{
		 text-decoration: none;
		 border: none;
		 /* any other customizations to that link here you want to override the global/default*/
	}
	</style>
</head>
<body>
	<a href="page.html" class="custom">Sample</a>
</body>
</html>

Open in new window

0
 

Author Comment

by:don0don
ID: 24110569
I hope you'll forgive a newbie question, bit regarding the /* THE CSS */ part of your instructions: would I need to add a separate class for each image on each page that I want to exclude from the global CSS formatting? In other words, here would be a separate <a href> statement for each image, pointing to the page name and the <img src> of each image?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:David S.
ID: 24111544
You would only need to use different classes if you wanted some of the styles to be different. Multiple elements may belong to the same class and an element may belong to multiple classes. The [X]HTML class attribute's value may be a space separated list of classes.

IDs, on the other hand, should be unique. In other words, two elements in the same document may not have the same ID.
0
 

Author Comment

by:don0don
ID: 24111743
OK.

I've added this to the top of the page, at the bottom of the HEAD section:

     <!-- CSS CUSTOM CLASS -->
             <style type="text/css">
             a.custom
             {
                      text-decoration: none;
                      border: none;
             }
             </style>

     </head>

... and I've added class="custom" to each of the <a href> statements, immediately after the page link (see the code snippet).

Doesn't work ... the linked images still have borders around them.

Obviously, I'm doing something wrong.

Sorry to be such a bonehead about this ...



        <td width="188"><a href="Billboards_Banners.htm" class="custom" target="_blank"><img src="picts/Cat_Bill_Bann.jpg" title="Billboards & Banners" width="188" height="125" onMouseOut="MM_effectAppearFade(this, 1000, 50, 100, false)" onMouseOver="MM_effectAppearFade(this, 1000, 100, 50, false)"></a></td>

Open in new window

0
 
LVL 42

Assisted Solution

by:David S.
David S. earned 125 total points
ID: 24113423
No, you did what was suggested. Actually the border is applied to the <img>, not the <a>. You can use the comma to make the rule apply to <a> elements that belong to the "custom" class and <img> elements that are descendants of such an element.
             <style type="text/css">
             a.custom, a.custom img
             {
                      text-decoration: none;
                      border: none;
             }
             </style>

Open in new window

0
 
LVL 13

Expert Comment

by:qwerty021600
ID: 24114561
a.custom img, img
             {
                      text-decoration: none;
                      border: 0;
             }
0
 

Author Closing Comment

by:don0don
ID: 31568607
I split the points because level9wizard was on the right track and Kravimir's tweak took it all the way to success. Thanks for your help!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question