HTML Image Border Using CSS
The CSS border
property is used to set a border to an image in a webpage.
It is used to specify the width, style and color of the border around the image in a webpage.
Example of Border of Image
Create an HTML <img>
element and add src="logoimage.jpg"
attribute to the image element to specify the relative URL of the image.
Add CSS inline style style="border:1px solid red;"
in the HTML <img>
element.
Here "border"
is the CSS property name and the value of the property "1px solid red"
refers that the border width is 1px solid in style and color of the border is red.
Have a closer look at the following example:
Example of HTML Image Border
Output of the above example
Example of Image Border in a Webpage
In the above example, CSS inline style is used to set border to the image.
style="border: 1px solid red;" is the css border style. Here the color of border line is red, line style is solid and width is 1px.