HTML code on Sharepoint Webpage

Anonymous
2024-09-13T12:21:14+00:00

Hi team, i hope you are well. I am about to create a sharepoint web page. However, i am trying to see how i can adjust my page by using html code or any other programming language. I saw the SPFx but it adjusts a specific web part but i would like to adjust the whole page. Is that doable?

Microsoft 365 and Office | SharePoint | For business | Other

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
{count} votes

7 answers

Sort by: Most helpful
  1. Anonymous
    2024-09-13T14:34:43+00:00

    Dear Christos Katsaitis Private,

    I hope you're doing well too! When it comes to adjusting a SharePoint webpage, you’re correct that SPFx (SharePoint Framework) is mainly used for customizing specific web parts. Unfortunately, SharePoint does not support direct HTML or full-page customization with programming languages for the entire page in the way traditional websites do.

    However, you do have a few options:

    Use a Script Editor Web Part (deprecated in modern SharePoint):

    In classic SharePoint, you can use a Script Editor Web Part to embed HTML, CSS, and JavaScript directly into a page.

    First make sure you have enabled the custom script, Enable Custom Scripts for a Site in SharePoint Admin Center.

    Here is how:

    • Sign in to the SharePoint Admin Center: https://<tenant>-admin.sharepoint.com.
    • Expand “Sites” and click “Active sites” from the left navigation. Select the site from the list by clicking on the site name link.
    • On the site properties panel, Click on the Settings tab. Click on the “Edit” link under “Custom Scripts”.
    • Select “Allowed” settings for Custom scripts. Click on “Save” to commit your changes.

    Then please go to site pages library, create a new "webpart" page.

    Click Add a webpart > Under "Content and Media" category, find "Content Editor" or "Script Editor" and insert it. You can add your HTML code here.

    To add an HTML code to modern pages:

    • Open your SharePoint Online site in the web browser.
    • Upload the .aspx file and its associated resources, like scripts and images, to any of your SharePoint libraries, such as “Site Assets”. Ensure any references to these images/styles/scripts are updated in the ASPX file.

    • Once uploaded, navigate to the page where you would like to add HTML code and edit the page.
    • Insert an “Embed” web part wherever relevant. This web part allows you to display HTML code directly into the web part. You can use this method if you want to add a small piece of code from another page. Set the Embed source address to the ASPX file you have uploaded.

    Use Third-Party Tools and Solutions:

    There are also third-party tools and solutions available that can help you customize SharePoint pages, including some that allow you to directly edit the HTML and CSS of modern SharePoint pages. However, it's important to carefully evaluate these solutions to ensure they meet your needs and are compatible with your SharePoint environment.

    In summary, while it's not possible to directly edit the HTML of a modern SharePoint page like you might in a traditional web development environment, you may choose upper several available options for customizing SharePoint pages to meet your needs.

    Should you have further queries, please feel free to reach out.

    Best regards,

    0 comments No comments
  2. matt howell 3,496 Reputation points
    2024-09-14T04:02:40+00:00

    A simpler option would be to add the modern script editor web part which lets you inject html/js/css in to your page. It's easy to deploy and made by expert 3rd party developers using core Sharepoint functionality. Not a Msft product so better made and more reliable.

    https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-script-editor/README.md

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2024-09-16T08:11:33+00:00

    I'm not able to add modern script editor webpart in any of the site collection now, earlier I was able to do the same. It shows in the backend list of available webparts, however not able to add the same in the page. Any idea?

    0 comments No comments
  4. matt howell 3,496 Reputation points
    2024-09-16T13:02:56+00:00

    I've never come across that. I made the web part available to all sites and just have to add it to the site if needed. Are the web parts you already added still working?

    I'd get the latest version if you don't have it and replace the app If you have a test tenant maybe try adding it there.

    0 comments No comments
  5. Anonymous
    2024-10-03T10:48:19+00:00

    Dear,

    according to: MC714186 - Remove Custom Script setting in OneDrive and SharePoint going into effect mid-november.

    We will no longer be able to use your proposed solution 'To add an HTML code to modern pages'.

    reffering to: learn.microsoft : Allow or prevent custom script

    'Uploading files that potentially include script

    The following file types cannot open from a library.asmx / .ascx / .aspx / .htc / .jar / .master / .swf / .xap / .xsf'

    Is this correct? Are there any other recommendations?

    0 comments No comments