1

I'm using an a tag in my html page which uses a css i can't place or modify. In the defined css a:link is styled in a way i dont want to use in my html file.

How can i use my a tag in order to delete any present styling inherited from the css, without modifying the css file?

Something like

<a href="foo.bar" style="none">foobar</a>

maybe?

Remember, for now I cannot modify the css file!

3
  • 1
    Nope. Sadly you'll have to reset all the CSS styles that are being applied. style="line-height: normal; color: inherit; etc. etc.
    – Pekka
    Commented May 20, 2013 at 13:14
  • 1) Check with what the other links are styled. 2) Find out what the default for these properties is. 3) Put these defaults together in that <a>'s attribute.
    – 11684
    Commented May 20, 2013 at 13:15
  • Or, just thought of it, give it an ID, then in the CSS file append :not(#linkID) to the selector with which you style the other links. That's only slight editing of the CSS file.
    – 11684
    Commented May 20, 2013 at 13:16

2 Answers 2

3

You need to reset all the styles applied to the element, unfortunately.

If for example your anchor tag had the following styles:

a {
    color:#f00;
    font-weight:bold;
    font-size:100px;
    background:#00f;
    text-decoration:none;
    /* Etc... */
}

To reset it you'd have to specify:

<a href="foo.bar" style="color:#000;font-weight:normal;font-size:16px;background:transparent;text-decoration:underline;<!-- Etc... -->
">foobar</a>
2
  • i've found the styles, can you help me setting the defaults? display:inline-block; float:right; height:20px; width:80px; color:#FFF; line-height:10px; text-align:center; background-color:#666; border-radius:3px; text-decoration:none; font-size:10px; box-shadow:0 1px 0 #000; padding:5px;
    – tony danza
    Commented May 20, 2013 at 14:45
  • 2
    Well the defaults are whatever those values should be on your site. At a guess: display:inline; float:none; height:inherit; width:inherit; color:#00f; line-height:inherit; text-align:left; background-color:transparent; border-radius:0; text-decoration:underline; font-size:16px; box-shadow:none; padding:0; Commented May 20, 2013 at 14:48
2

Okay, I thought of three ways until now:

  1. Find out what styles would apply to this link and put the defaults of these style rules in the style attribute of that single <a>.
  2. Give that <a> an ID and append :not(#linkID) to the selectors with which you select the other links. That's only slightly editing the CSS file.
  3. Put that single link in an <iframe>. The CSS of the containing document doesn't affect the content of <iframe>s as far as I know.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.