Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Anchor, Disable Style

Tags:

html

css

anchor

I have some html anchor link code, and unlike the rest of document I want it to look like it is not a link.

Is there a simple way to disable the style change caused by wrapping text in a anchor tag without having to brute force it to be the same (ie, if I change the body font style I don't have to also change some other :link stuff).

like image 1000
Jonathon Avatar asked Jul 29 '11 02:07

Jonathon


People also ask

How do you remove an anchor styling?

By setting the text-decoration to none to remove the underline from anchor tag. Syntax: text-decoration: none; Example 1: This example sets the text-decoration property to none.

How do I make anchor tag disabled?

You can always use tabindex="-1" inside your anchor tag in order to disable it.

How do you remove an anchor color?

Set red color to the text using the hex code #FF0000 . Then, set the text-decoration property to none . The CSS below will set the text Next Page to red which is a hyperlink. The text-decoration property, which is set to none , will remove the underline and blue color of the element of the anchor tag.

How do I turn off HTML tags?

The best way to disable a link tag is by using the CSS property pointer-events: none; . When you apply pointer-events: none; to any element, all click events will be disabled. Because it applies to any element, you can use it to disable an anchor tag. By using a CSS class, you can disable multiple anchor tags at once.


2 Answers

Setting color to black and text-decoration to explicitly none is a little more aggressive than worked for me.

I was looking for the CSS of the anchors to be "benign" and just blend into the existing CSS. Here's what I went with:

a.nostyle:link {     text-decoration: inherit;     color: inherit;     cursor: auto; }  a.nostyle:visited {     text-decoration: inherit;     color: inherit;     cursor: auto; } 

Then I just added the CSS nostyle class to the anchors that I wanted to be unformatted.

like image 75
Jeff Fischer Avatar answered Sep 22 '22 16:09

Jeff Fischer


I achieved this by creating a class .reset-a and targeting all of its' pseudo classes.

Targeting of all pseudo classes is important to make it flawless.

outline: 0 property removes the dotted border that surrounds a link when it is focused or active.

.reset-a, .reset-a:hover, .reset-a:visited, .reset-a:focus, .reset-a:active  {   text-decoration: none;   color: inherit;   outline: 0;   cursor: auto; } 
like image 30
Markandeya Avatar answered Sep 22 '22 16:09

Markandeya