Is there any way to format text in SharePoint image captions?

Anonymous
2025-01-17T18:37:43+00:00

Is there any way to apply standard formatting, such as italics or font color, to captions on images in SharePoint pages? I am more interested in this for images placed in Text web parts, but I also can't format caption text for the Image web part.

Microsoft 365 and Office | SharePoint | For education | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2025-02-08T06:08:32+00:00

Dear James,

Yes, you are right.

Based on my test, custom script needs to be enabled for the Embed web part with HTML code. The administrator can enable it every 24 hours via SharePoint Online Management Shell. Set-SPOSite https://contoso.sharepoint.com/sites/sitename -DenyAddAndCustomizePages 0

The SPFX solution is the alternative way of the custom script. It runs within the SharePoint Framework and doesn't rely on the custom script settings for its execution.

@Webbrewers, there may be no specific article about that currently. Similarly, you can see the detailed information about the SPFX part in Security considerations of allowing custom script - SharePoint in Microsoft 365 | Microsoft Learn.

Thank you for your time and effort.

Sincerely

Cliff | Microsoft Community Moderator

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

28 additional answers

Sort by: Most helpful
  1. Anonymous
    2025-01-18T07:06:17+00:00

    Thanks much, @Cliff Gu MSFT. In your Embed solution, you say to "convert the .html file as .aspx file". How do you do that conversion?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2025-01-18T06:49:28+00:00

    @Tommy(#81) Thanks for your offered solutions. In your option 4, I think that you are right to place the overlay text outside of SharePoint; the overlay text option that is available within SharePoint is nearly useless, because that overlay text disappears if the image scales too small. However, text directly in the image has accessibility problems.

    Your option 1 intrigues me the most. How can you add HTML tags to a Text web part? In his answer, @Cliff Gu MSFT seems to confirm that HTML cannot be added to a text web part.

    Concerning your option 2: As far as I can tell, the Markdown web part cannot do anything that a Text web part can't also do. Am I missing something? I can't find a decent reference for the SharePoint version of Markdown. The Microsoft Support page is not helpful.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2025-01-18T03:52:49+00:00

    Dear James,

    With caption text formatting, you need to use CSS code. However, the text web part and the Image web part may not insert the HTML and CSS code. To insert the HTML code and CSS code, you need to use the SPFX Modern Script Editor web part which may not be applied to your environment as it needs to be applied by the administrator and additional steps with the SPFX solution.

    Where are the Content editor and Script editor web parts in SharePoint? - Microsoft Support

    So given the situation, you may create a HTML file with the image and the formatted caption text like the following example from a web site, convert the .html file as .aspx file, save the file to the site library in your site and then use the Embed web part and type the file path such as https://contoso.sharepoint.com/sites/sitename/library name/filename.aspx (Replace the bold part with the names in your environment.) to see the result.

    <html>

    <head>

        <style>

            body {

                text-align: center;

                font: bold italic large sans-serif;

            }

        </style>

    </head>

    <body>

        <figure>

            <img src=

    "https://media.geeksforgeeks.org/wp-content/uploads/geeks-25.png"

                 alt="gfglogo" style="width:50%">

            <figcaption>Code World</figcaption>

        </figure>

    </body>

    </html>

    Welcome to share any updates at your convenience.

    Thank you for your time and effort.

    Sincerely

    Cliff | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2025-01-18T01:38:12+00:00

    Hi James,

    Thanks for reaching out. Currently, SharePoint Online does not natively support formatting for image captions in Image Web Parts or Text Web Parts, but there are workarounds you can try:

    1. Use HTML Formatting in a Text Web Part
      • If you’re adding an image inside a Text Web Part, you can use basic HTML tags to format the caption:
          <p><i>This is an italicized caption</i></p>  
          <p><span style="color:blue;">This is a blue caption</span></p>
        
      • This method works best when inserting an image manually inside a Text Web Part, rather than using the Image Web Part.
    2. Use the Markdown Web Part
      • If your SharePoint site allows Markdown, you can format text using:
          *This is italicized*  
          **This is bold**  
          [This is a link](https://example.com)
        
      • This will not work directly in an Image Web Part but is an option for captions inside a Text Web Part.
    3. Embed a Custom HTML Web Part (If Allowed)
      • If your organization allows custom scripts, you can use an Embed Web Part to insert formatted captions with custom CSS:
          <style>
            .caption { font-style: italic; color: red; font-size: 14px; }
          </style>
          <figure>
            <img src="https://yourimageurl.com" alt="Sample Image">
            <figcaption class="caption">This is a styled caption</figcaption>
          </figure>
        
      • This works well for advanced formatting but requires permissions to use custom scripts.
    4. Overlay Text Using an Image Web Part (Workaround)
      • If you need text formatting on an image caption, one alternative is to edit the image before uploading, adding styled text directly to the image using a tool like PowerPoint, Paint, or Photoshop.
      • Then upload the edited image to SharePoint, and no additional formatting will be needed.

    At this time, the best option is using HTML formatting in a Text Web Part or editing images before upload. Let me know if you need further assistance.

    Best regards,
    Tommy

    Was this answer helpful?

    0 comments No comments