I have a blog but most text seems to get underlined automatically. I am trying to find the text-decoration: underline but I can't seem to locate it. This is my blog
www.latestforpc.com
This is the line that causes the underline but I can't find it in style.css
a:-webkit-any-link {
color: -webkit-link;
text-decoration: underline;
cursor: auto;
}
Web browsers are designed to add default styling to page elements even without that styling being explicity mentioned in the page's stylesheet. In order to change this default behavior, you have to add this code to style.css:
a { text-decoration: none; }
This will overwrite the browsers default styling for your links, and in this case, remove the underline.
If you inspect a link in your browser, like you did, you can find that style, and it also shows you in which CSS file the style is declared.
In this case it says 'User agent stylesheet'. That actually means that it is a default style in your browser (the stylesheet that is built in into your user agent). So that's why you cannot find it.
Now, to fix it, you can add a rule to style.css that overrules this default style:
a {
text-decoration: none;
}
That should be enough. The styles in your css file have higher priority than the defaults of the browser.
Just add the following at the bottom of your CSS;
a {
text-decoration: none;
}
and if you want your links to appear underlined when hovering over them, also add;
a:hover {
text-decoration: underline;
}
Done!
It looks like you have multiple style sheets on your site, so that style could be in any of the style sheets. You might try adding the following in your master css file to override the other style sheets:
a { text-decoration: none !important;}
There are many "browser stylesheets" in browsers like user agent stylesheet in chrome. They are pretty good but sometimes we need to get rid of them. So we use "reset.css"
Or you can only add
* {text-decoration:none;}
if you just want to get rid of the underline
Is there a way to reset visited and unvisited link colours to the browser default after they have been changed?
In my specific situation, I have a main style file containing:
a:link { color: black; }
a:visited { color: black; }
And I would like to have a few specific links rendered with the default colours.
EDIT: Here is a jsFiddle to play with. I would like a style for the default class that makes it match the browser default.
Edit:
Another way is avoiding the problem from the beginning. Give the special links you want to be with the default style a special class (let's call it .default), and instead of:
a:link { color: black; }
a:visited { color: black; }
Use the not pseudo class and write:
a:not(.default):link { color: black; }
a:not(.default):visited { color: black; }
Notice that this pseudo class doesn't work on IE 8 and lower. For them you can use a special CSS (I don't like it, but it'll work).
It is different for each browser.
What you would have to do is get a stylesheet from the browser you are trying to reset (Gecko, WebKit, or Trident) and make that the new default.
Source: Browsers' default CSS for HTML elements
What you're looking for is revert keyword, but it's not yet implemented in most browsers, currently only Safari supports it. The links to track the development per browser are listed in the Browser compatibility section on MDN.
Some day this should work everywhere:
a { color: red; }
a.reverted { color: revert; }
red <a class="reverted" href="#">default</a> red
But for now think about a workaround. The feature is just not there yet.
If that is the only css controlling your a tags then just remove those and that will take off any styling. You could also just change the color?? Like so...
a:link {color: blue;}
a:visited {color: purple;}
Nowadays we can do something like this:
<head>
<style>
:link { color: black; }
:visited { color: black; }
.default-color :link { color: LinkText; }
.default-color :visited { color: VisitedText; }
</style></head>
<body>
<a href='#'>link</a>,
<span class='default-color'>
<a href='#'>link</a></span></body>
The second link renders with default colours.
See: CSS Color Module ยง System Colors
You can only fiddle with the URL. Browsers record the URLs they've visited. If they're rendering a page, and a particular URL appears in that list, then url is colored as "visited".
You can't force a browser to treat a URL as visited, unless they've actually been there. But you CAN make a visited URL appear as "new" by adding something different to the url, so that it APPEARS new to the browser. e.g.
example.com/foo.php
example.com/foo.php?random=value
both point at the same script, but the browser will treat both as "different". If that random value changes each time, the the browser will effectively think each time it's a brand new url and color it as "new".
I guess one question to ask here is: why? Why would you want to do that in the first place? To my knowledge, there's no W3C standard delineating what default link colors should be, anyways. A value (such as default) for color wouldn't make sense at all, seeing as that the isn't a default value.
With that being said, the most logical way to go about this would to just style things yourself. I'm not sure what situation your in, but whatever the case is, I'm pretty sure you're doing something wrong if you're asking how to restore colors to the browser default. So, before I give you a rather dry solution, I'll ask: can you give us some context? In the case that you're making something like menu bar links and you don't want the same styling for those menu bar links to leak into your normal links, you should really be using some kind of container to select those links in.
Anyways, here comes that dry solution. Most browsers use blue for links, purple for visited links, and red for active links. So, something like the following would work for browsers that go by these colors (assuming that the user hasn't modified the browsers' styling sheet, in which case you may want to learn about that or use something like initial, examined in Itay's answer).
a:link, a { color: blue; }
a:visited { color: purple; }
a:active { color: red; }
enter code herea.class{
color:inherit;
}
Specifies that the color should be inherited from the parent element.
so if your body was color:blue; then followed by a.class{color:inherit} then those examples would be blue. at the same time, you could just use a.class:link{color:blue}. and another for when you visit the link.
Your best with just customizing classes of links of special interest and leaving the rest by default.
No, you cannot set any CSS property to the browser default if it has been changed (i.e., if there is any style sheet being applied that assigns a value to the property. This follows from basic principles of CSS.
So consider asking a different question. There are ways to limit the effect of CSS rules to specific elements, instead of e.g. preventing all links from looking like links.
Just style the ones you want to style by setting a class on them.
.class:link{}
.class:visited{}
Then leave the others default.
You can use this:
a {
color: inherit;
}
That will inherit, and as there is no other link color so the browser will give the link its own style!
I am trying to highlight the current menu item in wordpress. I have tried the following code:
#menu-menu li.current-menu-item a { background-color:#d9707a; }
#menu-menu li.current_page_item a { background-color:#d9707a; }
The above code is working fine but what actually I am trying to do is highlight by changing the color, so I tried the following code but its not working
#menu-menu li.current-menu-item a { color:#d9707a; }
#menu-menu li.current_page_item a { color:#d9707a; }
Could you please tell me how to solve this problem?
We don't know enough of your setup to know what the exact problem is. But it sounds to me that your color style might be being overwritten due to style specificity.
Either track down the style that is overwriting the color (using your browsers inspector) and change it there (but you need to confirm that it is safe to do so, as that style might be affecting other parts of your site) OR, the quick and dirty method of adding an !important tag to your styles.
Example:
#menu-menu li.current-menu-item a { color:#d9707a !important; }
#menu-menu li.current_page_item a { color:#d9707a !important; }
More info on style specificity:
What are the priorities among CSS selectors
Understanding CSS selectors
I have this CSS code for links on my site:
a { text-decoration:none; color:#2B5384; }
a:hover { color:#F90; }
a:visited { color:#2B5384; }
It works fine if the link looks like that: My page - the color of the link is dark blue, on hover it changes to orange and the underline appears.
However, if I link to external website, for example My page - on hover the link doesn't change the color and no underline appears. It works if I change the URL to have the .html extension - My page, but, obviously, there's no such page.
Why is it happening and how can that be fixed?
see http://www.w3schools.com/css/css_pseudo_classes.asp especially the notes :
Note: a:hover MUST come after a:link and a:visited in the CSS
definition in order to be effective!!
Note: a:active MUST come after a:hover in the CSS definition in order
to be effective!!
Note: Pseudo-class names are not case-sensitive.
Here's the official w3c take on it http://www.w3.org/TR/CSS2/selector.html see section 5.11.3
I have a custom cursor for an image map with a lot of hotspots. My cursor works fine in Firefox and Internet Explorer, but Safari returns the default one.
I used code found on other websites. My directory structure is:
index.php > css/main.css > css/images/pencil.cur
Here is my implementation (please note I need the same custom cursor for both normal and a, a:hover and a:visited states:
#gameScreen area, #gameScreen .wrapper, #gameScreen .wrapper a:hover, #gameScreen .wrapper a:visited {
cursor: url("images/rcspencil.cur"),url("css/images/rcspencil.cur"),default;
}
Any ideas?
Here's the most browser-compatible syntax I can think of. There might be a better one with browser hacks but I'd ignore it.
cursor: url(cursor.cur),url(cursor/cursor.cur),default;
I wouldn't think the quotations would prevent it from working, but try it without them. The only other thing I can think of is that your selectors are wrong, like the selectors you've got listed don't include the thing you're hovering over.