Borders on All Images (HTML)
You can use CSS to add borders around all images, based on the image type. For example, you could add borders around all block images, but leave inline images to have no borders.
With images that are inside figures and informalfigures, you also have the option to add a border around the entire figure/informalfigure section. So you could have a border around the section, but not the image. Or you could have different borders around both.
![]() |
To use CSS to style image borders for HTML ouputs, follow the steps below. Note that for the examples provided, we have used a pink dotted border that is 3px wide. There is 1em padding (internal margin) on each image too. You can change the sizing, style, and padding as required.
Tip
For information on using CSS for border styles, we recommend the w3schools website.
Use a code or text editor to create a CSS file. Give it a suitable name and save it with the
.cssextension.Note
If you already use a custom CSS for your layout, you should edit that CSS file instead.
Enter the CSS for the border styles you want.
To style block images, add your border styling for the
.mediaobject imgclass. For example:.mediaobject img { border: 3px dotted #FF1493; padding:1em; }To style figure sections, add your border styling for the
.figureclass. For example:.figure { border: 3px dotted #FF1493; padding:1em; }To style informalfigure sections, add your border styling for the
.informalfigureclass. For example:.informalfigure { border: 3px dotted #FF1493; padding:1em; }To style inline images, add your border styling for the
.inlinemediaobjectclass. For example:.inlinemediaobject { border: 3px dotted #FF1493; padding:1em; }Note
The
figureandinformalfigureclasses are for styling the figure and informalfigure sections, not the images inside them. The images inside the sections are either block images that you can style withmediaobject imgor inline images that you can style withinlinemediaobject.Save your CSS file.
When you publish with that layout, the CSS styles will be applied to your published output.





