0

hey guys i want to know that how to remove border/outline from image tag, include that i am not using image in it , for example test code fiddle

HTML

<img src="" class="testClass">

CSS

.testClass{
    width: 100%;
    margin-left: 0%;
    height: 150px;
    border: 0px;
    outline : none;
}
vishal
  • 1,368
  • 2
  • 15
  • 34
  • 1
    thats ok what you do, i do not understand you. – vaso123 Oct 28 '14 at 16:15
  • 5
    If you're not using an image, don't use an img tag. The display of missing images is very browser dependent and you shouldn't plan on controlling it. – Scott Saunders Oct 28 '14 at 16:16
  • oh, i did not realized, he do not use image. sorry. – vaso123 Oct 28 '14 at 16:17
  • @ScottSaunders is right. If you absolutely must have an image tag that points to a broken URL (or non-existant, like #), then try instead pointing it to a blank.gif. – Mike Willis Oct 28 '14 at 16:17
  • 1
    If your trying to catch broken images check out http://stackoverflow.com/q/92720/2033671 –  Oct 28 '14 at 16:20
  • i have to add image source dynamically, so i have to compulsorily put img tag there – vishal Oct 29 '14 at 04:28

2 Answers2

2

What you see there is the browser's "broken image URL" image. That's what you get when the browser can't load the image. It doesn't have a border; the browser just renders something so you can see how big the missing image would be. Therefore, you can't influence the result with CSS much.

What you can do is set display: none to hide the image altogether. If you want the space to be empty, wrap it in a div with the same size.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • i have to add image source dynamically, so i have to compulsorily put img tag there – vishal Oct 29 '14 at 04:26
  • @vishal - if the img has no image path you could remove the image completely with `img[src=""] { display: none }` (IE 8 +) [Example here](http://jsfiddle.net/tbjjzjj8/) – misterManSam Oct 29 '14 at 05:20
  • @vishal: Try this: Put an empty DIV there and create the whole `img` element dynamically. – Aaron Digulla Oct 29 '14 at 08:25
0

Display none would remove the image, so it destroys the space it occupies, not good for the layout. Also it causes a map with areas to be inaccesible. I use an empty image to create some clickable areas for some underlying elements, so I don't want an image. The only option that works is to set opacity to 0.