How can we help you today?

How to Add Custom CSS Using ShortPoint Code Editor Web Part

Learn how to customize your Modern SharePoint pages with custom CSS using the ShortPoint Code Editor Web Part. This simple guide will walk you through adding custom styles to enhance your SharePoint pages. Follow our Quick Walkthrough for concise instructions or use our detailed step-by-step tutorial.


TABLE OF CONTENTS


Prerequisites

  • The ShortPoint Code Editor Web Part is installed on your SharePoint site. To learn how to do this, read our article on How to Install ShortPoint Code Editor in SharePoint.
  • You have the appropriate SharePoint permissions to edit the page where you want to add custom CSS code.

Quick Walkthrough

  1. Get your custom CSS code ready. Either write it yourself or obtain it from a trusted source, then copy the code to your clipboard.
  2. Go to your SharePoint page and click the Edit button to enter edit mode.
  3. Add ShortPoint Code by clicking the + button and selecting it from the web parts library.
  4. Click the Edit properties button.
  5. In the CSS field, paste your custom CSS code.
  6. Review and customize your code. Adjust parameters to match your needs.
  7. Republish the page.

Step-by-step Tutorial

You can either write custom CSS code to style your SharePoint web parts and pages, or use CSS snippets shared by SharePoint experts online. In this tutorial, we'll show you how to apply custom CSS to give your SharePoint web parts rounded corners.


Just like this SharePoint Banner web part:


banner rounded


Here's how to add custom CSS code to your page:


Step 1: Copy custom CSS code

  • Prepare your CSS code by writing it yourself or obtaining a code snippet from a trusted source. In our example, we’ve written a custom code to apply rounded corners to a SharePoint web part.
  • Copy this code to your clipboard.


[data-sp-feature-tag="PageTitle web part (Banner)"] { /* this selector can be found by inspecting the web part */
    border-radius: 20px;
    overflow: hidden;
}

This CSS code rounds the corners of the SharePoint Page Title Banner web part. You can customize the code by adjusting the following before copying:

  • The selector [data-sp-feature-tag="PageTitle web part (Banner)"] can be replaced with other web part tags. To find the right selector, inspect the web part you want to style.


web part tags


  • The value "20px" for the border-radius can be adjusted to any pixel size you want.
  • This CSS code requires you to disable the Contain CSS Styles feature.

Step 2: Edit the SharePoint page

  • Go to the SharePoint page where you want to apply custom styling.
  • Hit the Edit button.


Edit the SharePoint page


Step 3: Add the ShortPoint Code web part

  • Close the Toolbox to get a full view of the page while editing.


Close the toolbox


  • Click the + icon to Add a new web part.


Add new web part


  • Search for ShortPoint Code in the web parts library and select it.


select ShortPoint Code


Default content will appear on your page.


default ShortPoint Code content


Step 4: Edit properties and customize

  • Hit the Edit properties button. This will open the ShortPoint Code Editor window.
  • Remove the default content and paste your copied code in the CSS field. You can also edit the code in the expanded editor view.
  • Delete other codes in the HTML and Javascript fields.
  • Disable the Contain CSS Styles toggle.

The SharePoint web part will now display with rounded corners.


Add custom CSS


Step 5: Republish the page

When you're ready to share your changes, click Republish. Your users will then see the new styling on your Modern SharePoint page.


That's it! You've learned how to apply custom CSS styling to your SharePoint page using the ShortPoint Code Editor web part.


Related articles:




Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 18 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more