标签云

微信群

扫码加入我们

WeChat QR Code

When I turn an image (<img>) into a hyperlink (by wrapping it in <a>), Firefox adds a black border around the image. Safari does not display the same border. What CSS declaration would be best to eliminate the border?


This solution helped me out a lot, wish I'd found it before the 2 hours of frustration! But I think using "a img{border: 0;}" is a better fitted solution to the original problem - the emphasis on the initial "a" because the problem only occurs when an image is wrapped in a hyperlink

2018年08月17日12分36秒

attention: Your <img> tag is not correct. Either you have to use " to quote the border attribute value (because XML requires that), or you have to remove the / before the ending > (because SGML/HTML doesn't allow that)

2018年08月16日12分36秒

pilif not to mention, uh, that <img> has href and not src...

2018年08月16日12分36秒

That's invalid CSS: '0' does not have a unit. Should just be "border-width: 0;".

2018年08月17日12分36秒

what rule says 0 can't have a unit?

2018年08月17日12分36秒

0 might not have a unit, but px does have a length...

2018年08月16日12分36秒

BobbyJack Of course 0 needs a unit. Even if it can be derived from the context, all numbers (and 0 is a number) need a unit to be meaningful. The browser automatically adds the 'px' if you leave it off, cleaning up for your laziness - but it still needs to be there.

2018年08月17日12分36秒