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-31T21:50:46+00:00

    Thanks, Cliff.

    I actually did understand that webbrewer's suggestion was for an SPFx extension, and I already knew that SPFx works for SharePoint online. He also mentioned SharePoint Designer, which was the reason for my question about it.

    • My understanding is that react-application-injectcss (webbrewer's suggestion) pulls the css code from a file in Site Assets, while the Modern Script Editor allows css code in a web part on a specific page. Is that correct? Are you saying that the Modern Script Editor is a more supported solution?
    • Regardless of these CSS options, I am still interested in the original solution of embedding an HTML file in a SharePoint page. I hope that you will be able to test that soon.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2025-01-30T07:32:57+00:00

    Dear James,

    What Webbrewers recommended isn't SharePoint Designer. It uses the SPFX solution (SharePoint Framework). Yes, it is applied to SharePoint Online. If you can find the administrator in your tenant, it is the best way to insert any code such as CSS, HTML, JavaScript and so on.

    Overview of the SharePoint Framework (SPFx) | Microsoft Learn

    You can let them deploy the Modern Script Editor web part to do that currently.

    Her is a guide for your reference.

    Installing Modern Script Editor by SPFx: How to for Dummies | Microsoft Community Hub

    Thank you for your time and effort.

    Sincerely

    Cliff | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2025-01-29T22:29:58+00:00

    Thanks for the pointer to react-application-injectcss. I am not an administrator for our tenant, but I can see whether they are willing to add this.

    Our organization is new to using SharePoint, and I'm not familiar with SharePoint Designer. Does that apply to SharePoint Online tenants?

    Was this answer helpful?

    0 comments No comments
  4. matt howell 3,511 Reputation points
    2025-01-29T20:12:59+00:00

    The best option is to inject a stylesheet using this method:

    https://github.com/pnp/sp-dev-fx-extensions/blob/main/samples/react-application-injectcss/README.md

    You can then edit your custom stylesheet directly in Sharepoint Designer with no need to download/upload.

    Futzing around with iframes seems like overkill to me.

    Bonus benefit: this solution can also be used to load a custom javascript file.

    Was this answer helpful?

    0 comments No comments