Jump to content

Image as Link


shadowx360

Recommended Posts

Hello,

 

I'm using an image as a link, and I basically create a new image element, set its source, create an "a" element, set it's href, and then I append the image as a child to the link. However, what I get is a button with a blue outline, as links are blue, and it automatically makes that blue outline on the button. I tried to force the border-color property to black (that's the background color of the page), but it still gives me that blue outline.

 

Any idea how to disable that, or turn it black?

Link to comment
Share on other sites

Do as suggested and set it in your CSS and not your JavaScript.  Regardless of how you're creating them the CSS rules will be obeyed.  If you start putting CSS in your JavaScript you are combining logic and presentation and making it harder to fix things later.

 

The CSS rule you're looking for is:

a > img { border: none; }

 

Or if necessary:

a > img { border: none !important; }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.