Skip to main content

Default Class Names for Images in HTML

All images in your published HTML content have a class name. You will need the class name to style the images with CSS.

By default, the class names are:

  • mediaobject for block images

  • inlinemediaobject for inline images.

In the published HTML, the mediaobject is the class name for a container <div> element, and the image is inside the <div>.

HTML code showing <div class="mediaobject"> on the top line, <div class="material-placeholder"> on the middle line, and <img class="materialboxed" with some other image metadata on the third line. A callout arrow points to the first line and a blue highlight box is around the third line.

Similarly, the inlinemediaobject class name is for a span element that contains the inline image.

HTML code showing <span class="inlinemediaobject"> on the top line, and image metadata on the second line. A callout arrow points to the first line and a blue highlight box is around the second line.

You can use a CSS selector to style the image inside the mediaobject and inlinemediaobject "containers". For example, to put a border around all mediaobjects, you could create a CSS file containing the following styling:

.mediaobject img {
border: blue;    
border-style: dashed;
}

You would then upload that CSS file to your CSS layout and publish using that layout. The block images in your published output would then have a blue dashed line as a border.

An image with blue dashed border.

If you apply styling to mediaobject or inlinemediaobject, it will apply to all images that have that class name. So if the default settings are in place and none of your images have a custom class name, styling mediaobject will affect all of your block images and styling inlinemediaobject will affect all of your inline images.

If you only want to style specific images, you can give those images their own class names. There are two ways to do this: you can Custom Class Names for Images - Role Attribute or Custom Class Names for Images - Taxonomy Tag .