How to remove CSS underline? - css

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

Related

Can't modify style css for link

I am trying to override the classic blue colour of my links in my CSS file, but none of the options found on the web seem to work for me. I've also checked my cache so it's not that the changes don't appear. I'm checking in IE, Firefox and Chrome.
I tried:
a:link { color:red };
AND just in case:
a:link { color:red; }
OR:
a {
text-decoration: none;
}
No impact whatsoever.
I'd add a:
a:visited { color: red };
I am supposing you'd visited that links before; in that case empting cache has no effect....
Anyway difficoult to guess without the code.
Ok i fixed your Fiddle to make it work
https://jsfiddle.net/ehoav3oz/6/
There were severals sintax errors; fixed both CSS and HTML

Why does this element does not respect specificity rules?

So I was tweaking the Firefox built-in reader mode using Stylish extension. The first thing I did was to change the font:
body.loaded.serif div#moz-reader-content, h1#reader-title, div#reader-credits{
font-family: "Marion";
}
It worked fine. Later on I wanted to tweak the links:
a{
text-decoration: none;
}
And the links stay unchanged. I can see in Firebug that this declaration is overriden by the default style declaration (as in "aboutReaderContent.css") which also used a single selector. Then I tried making it more specific:
html body.serif.loaded div.content div#moz-reader-content p a{
text-decoration: none;
}
Still no effect. Firebug says it was still overriden. I had to resort to !important.
My question is, why did this element does not follow the specificity rule? As I understand it, even in multiple files, browser will follow the most "specific" selector regardless the order these files are loaded. To add to my confusion, the first tweak actually overrode the default stylesheet, but that's in another file "aboutReader.css". What am I missing?

Reset link colour to browser default

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!

A peculiar issue with css links

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

How can I remove the outline around hyperlinks images?

When we use Text Replacement using CSS and give a negative test-indent i.e. text-indent:-9999px. Then when we click on that link the Dotted line appears like in the sample image below. What's the solution for this?
For Remove outline for anchor tag
a {outline : none;}
Remove outline from image link
a img {outline : none;}
Remove border from image link
img {border : 0;}
You can use the CSS property "outline" and value of "none" on the anchor element.
a {
outline: none;
}
Hope that helps.
For Internet Explorer 9:
a:active, a:focus {
outline: none;
ie-dummy: expression(this.hideFocus=true);
}
Source: http://social.msdn.microsoft.com/Forums/en-HK/ieextensiondevelopment/thread/1023adfd-bd73-47ac-ba9c-2bad19ac583a
Please note that the focus styles are there for a reason: if you decide to remove them, people who navigate via the keyboard only don't know what's in focus anymore, so you're hurting the accessibility of your website.
(Keeping them in place also helps power users that don't like to use their mouse)
There is the same border effect in Firefox and Internet Explorer (IE), it becomes visible when you click on some link.
This code will fix just IE:
a:active { outline: none; }.
And this one will fix both Firefox and IE:
:active, :focus { outline: none; -moz-outline-style: none; }
Last code should be added into your stylesheet, if you would like to remove the link borders from your site.
include this code in your style sheet
img {border : 0;}
a img {outline : none;}
I hope this is useful to some of you, it can be used to remove outline from links, images and flash and from MSIE 9:
a, a:hover, a:active, a:focus, a img, object, embed {
outline: none;
ie-dummy: expression(this.hideFocus=true); /* MSIE - Microsoft Internet Explorer 9 remove outline */
}
The code below is able to hide image border:
img {
border: 0;
}
If you would like to support Firefox 3.6.8 but not Firefox 4... Clicking down on an input type=image can produce a dotted outline as well, to remove it in the old versions of firefox the following will do the trick:
input::-moz-focus-inner {
border: 0;
}
IE 9 doesn't allow in some cases to remove the dotted outline around links unless you include this meta tag between and in your pages:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
This is the latest one that works on Google Chrome
:link:focus, :visited:focus {outline: none;}
in order to Removing The Dotted Outline href link you can write in your css file:
a {
outline: 0;
}
If the solution above doesn't work for anyone. Give this a try as well
a {
box-shadow: none;
}
-moz-user-focus: ignore; in Gecko-based browsers (you may need !important, depending on how it's applied)
Use Like This for HTML 4.01
<img src="image.gif" border="0">
You can put overflow:hidden onto the property with the text indent, and that dotted line, that spans out of the page, will dissapear.
I've seen a couple of posts about removing outlines all together. Be careful when doing this as you could lower the accessibility of the site.
a:active { outline: none; }
I personally would use this attribute only, as if the :hover attribute has the same css properties it will prevent the outlines showing for people who are using the keyboard for navigation.
Hope this solves your problem.
I'm unsure if this is still an issue for this individual, but I know it can be a pain for many people in general. Granted, the above solutions will work in some instances, but if you are, for example, using a CMS like WordPress, and the outlines are being generated by either a plugin or theme, you will most likely not have this issue resolved, depending on how you are adding the CSS.
I'd suggest having a separate StyleSheet (for example, use 'Lazyest StyleSheet' plugin), and enter the following CSS within it to override the existing plugin (or theme)-forced style:
a:hover,a:active,a:link {
outline: 0 !important;
text-decoration: none !important;
}
Adding '!important' to the specific rule will make this a priority to generate even if the rule may be elsewhere (whether it's in a plugin, theme, etc.).
This helps save time when developing. Sure, you can dig for the original source, but when you're working on many projects, or need to perform updates (where your changes can be overridden [not suggested!]), or add new plugins or themes, this is the best recourse to save time.
Hope this helps...Peace!
I would bet most users aren't the type of user that use the keyboard as a navigation control. Is it then acceptable to annoy the majority of your users for a small group that prefers to use keyboard navigation? Short answer — depends on who your users are.
Also, I don't see this experience in the same way in Firefox and Safari. So this argument seems to be mostly for IE. It all really depends on your user base and their level of knowledge — how they use the site.
If you really want to know where you are and you are a keyboard user, you can always look at the status bar as you key through the site.
This works perfectly for me
a img {border:none;}
Any image that has a link will have a border around the image to help indicate it is a link with older browsers. Adding border="0" to your IMG HTML tag will prevent that picture from having a border around the image.
However, adding border="0" to every image would not only be time consuming it will also increase the file size and download time. If you don't want any of your images to have a border, create a CSS rule or CSS file that has the below code in it.
img { border-style: none; }
Yes we can use. CSS reset as a {outline:none} and also
a:focus, a:active {outline:none}
for the Best Practice in Resetting CSS, The Best Solution is using common :focus{outline:none} If you still have Best Option please Share

Resources