Aug 01 2024 01:42 PM
Hello everyone,
Is there a way to change the color of the table borders? Maybe by adding CSS styles to the page? I'm not sure if it's possible, and if so, I don't know how to do it either.
Thank you in advance,
Aug 02 2024 01:24 AM
In SharePoint Online, there are multiple ways to change the appearance of table borders or other styles. While custom CSS is a common approach.
SharePoint Online allows you to inject custom CSS through the use of script editors or content editor web parts, and if you have access to the SharePoint site, you can apply these custom styles. Here’s a step-by-step guide to help you achieve this:
Step 1: Create the CSS
First, you need to create a CSS file that contains the style definitions for your table borders. Here’s an example of a simple CSS code to change the border color of a table:
/* Custom CSS for table border color */
.custom-table table,
.custom-table th,
.custom-table td {
border: 2px solid #4CAF50; /* Change the color and thickness as needed */
}
Step 2: Upload the CSS to a Document Library
Step 3: Add the CSS to Your SharePoint Page
<link rel="stylesheet" type="text/css" href="https://yoursharepointsite.sharepoint.com/sites/yoursite/SiteAssets/customStyles.css">
<table class="custom-table">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Example:
If your table is part of a web part or a content area, ensure the table has the appropriate class to apply the styles.
<div class="custom-table">
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
</div>
Step 4: Save and Publish
By following these steps, you can change the border color of tables in SharePoint Online using custom CSS. Ensure you have the necessary permissions to edit the page and upload files to the document library.
While custom CSS is a straightforward way to style table borders in SharePoint Online, you have several other options, including JSON formatting for columns, Power Apps for complex forms, SPFx for custom web parts, and modern page web parts for direct embedding.
NOTE: Since no one has answered it for at least one day or more, I entered your question in an AI (Otherwise it would have cost the author a lot of writing time). The text and the steps are the result of AI. The answers of an AI should be treated with caution, as they are not always correct. Maybe it will help you further in your project, if not please just ignore it.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.
Aug 02 2024 01:52 AM
@ajdm73 AI as usual gives an inaccurate or incomplete answer. Modern SharePoint sites don't have the content editor web part. And the script editor/embed web part solution suggested is pretty horrid. Injecting CSS could be done with the SPFx framework but I'm no expert on that. Out of the box the only way to do it is to select the theme style.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
Aug 02 2024 06:23 AM
Hello!
Thank you very much for replying.
I installed a script editor on my SharePoint but it does not work as expected, I mean I have not been able to activate it for my sites.
Any idea?