www.webdeveloper.com
Results 1 to 4 of 4

Thread: apply a style for all links except one

  1. #1
    Join Date
    Mar 2007
    Posts
    13

    apply a style for all links except one

    hi everybody...

    i`m applying a style for all my links (ie: a { [...] }). ok, but i want that one link in particular doesn`t get that style.
    is there any way to accomplish tht without setting a class for all my page links?

    any hint would be much appreciated... :]

  2. #2
    Join Date
    Nov 2003
    Location
    Worthington, OH, USA
    Posts
    3,634
    How about just setting a different class on the one you don't want styled...
    54 68 65 42 65 61 72 4D 61 79

  3. #3
    Join Date
    Nov 2006
    Location
    Springfield, MO
    Posts
    1,541
    In addition to what was replied, this is probably what you want:

    All links that you want the same:

    Code:
    a:link
    a:visited
    a:hover
    a:active
    The one special link:

    Code:
    a.special:link
    a.special:visited
    a.special:hover
    a.special:active
    HTML:

    Code:
    <a href="somepage.html" class="special">Click me</a>
    Ryan Butler

    Ryan Butler.org

  4. #4
    Join Date
    Jul 2005
    Location
    South Carolina
    Posts
    395
    Following is a very simplistic example, but shows you another way to exclude an element. It uses the CSS child selector to say, 'anything that is a direct child of the body element will receive this style, and nothing else.' For an a tag, this is a valid approach since the a tag is inline; if a was a block-level element, it would not be valid XHTML 1.0 Strict.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>hello hello hello hello hello</title>
    <style>
    	body > a
    	{
    		color:red;
    	}
    </style>
    </head>
    <body>
    	<a>hello</a>
    	<a>hello</a>
    	<span id="no_class">
    		<a>hello</a>
    	</span>
    	<a>hello</a>
    	<a>hello</a>
    </body>
    </html>
    NOTE: This does not work in IE7 quirks mode. The DOCTYPE is required. Have not tested with DOCTYPES other than XHTML 1.0 Strict.
    I can solve differential equations and build huge databases, but I have no idea how to change my oil.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles