Two ways:
<img src="..." border="1" />
or
<img style='border:1px solid #000000' src="..." />
Answer from Diodeus - James MacFarlane on Stack OverflowHow to tell CSS to put a border around some images, but not other? - Stack Overflow
CSS Image Border Not Showing Up Completely (7.0)
Image border CSS help
How to make border image only for the bottom?
Videos
Mark the ones that should have a border with a class:
<img class='picture' ...>
and then use CSS to add the border:
.picture {
border: 1px solid green;
}
You could set a style for the images, as this:
<img src="yourimage.jpg">
img {border:2px dotted blue;}
And set a unique class for the other images such icons, as this:
<img src="youricon.jpg" class="noborder">
img.noborder {border:none;}
In any case you must make a difference between two images for the css identify each other.
I have a header and i want to add a border only to the bottom part of it, i have an image i want to use as the border, but there's no border-image-bottom, i was searching for ways to get over it, like making border-top/right/left at 0 and trying to use ::after, but neither worked.
This can be done by adding image in a div and than set the border of the div
Copy<div style="border:1px solid red;float:left;">
<div style="background:url("...");float:left;"></div>
<div>
Without specific implementation details it's very difficult (if not impossible) to provide a solution that works in all cases. Here's a couple solutions with the constraints provided:
Example 1 - Fixed Size
If you know the height and width of the background image you can do something like this:
Copydiv.bg {
background-image: url('http://www.google.com/images/logo_sm.gif');
border: 5px solid #000;
width: 50px;
height: 50px;
}
Copy<div class="bg"> </div>
Run code snippetEdit code snippet Hide Results Copy to answer Expand
Working example: http://jsfiddle.net/WUHmw/
Example 2 - Repeating Background Image
If the background image repeats, you can do something like this:
Copydiv.bg {
background: url('http://i.imgur.com/ikxbnvc.png') repeat;
border: 5px solid #000;
box-sizing: border-box;
width: 100%;
height: 200px;
}
Copy<div class="bg">
<p>Here is some text to on top of the background image.</p>
</div>
Run code snippetEdit code snippet Hide Results Copy to answer Expand
Working example: http://jsfiddle.net/pLz52/
No, there's no way to do that. You could add a second div that contains the image, but then you wouldn't be able to use background-size: contain.
If you knew that the image dimensions wouldn't change, you could add a second background-image, positioned in the same way, that was simply a transparent png with the border you wanted... but that would be really silly.
Unfortunately I don't have the time to create a working example right now, but a possible workaround may be the use of multiple backgrounds: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Background_and_Borders/Using_CSS_multiple_backgrounds
The second background could be an SVG rectangle with a stroke. To avoid possible stroke deformation due to scaling, use non-scaling stroke: https://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke