A Short Overview of the Guide
This guide provides detailed step-by-step instructions on how to apply custom CSS to CRM forms, which means using a combination of JavaScript and web resources, including several examples of its use.
A Short Reference About the Author
Mykhailo is a qualified Dynamics 365 Developer with deep practical experience working with Dynamics 365 and the Power Platform, including developing and customizing Dynamics 365 CRM and connected external portals.
Introduction
Customizing the appearance of Microsoft Dynamics CRM forms can significantly reinforce user experience and align the CRM interface with your company's branding. Applying custom CSS to CRM forms involves a combination of JavaScript and web resources.
Practical Considerations When Applying Custom CSS in Dynamics 365
When applying custom CSS to Dynamics 365 CRM forms, it is important to understand which elements can be modified effectively and how to apply changes without affecting the overall user experience. Custom CSS is commonly used for visual improvements such as changing field appearance, highlighting important information, adjusting spacing, hiding unnecessary visual elements, and improving the readability of forms.
Some of the most common practical scenarios may include the following:
-
Highlighting important fields
CSS can be applied to fields such as status, priority, approval indicators, or customer information to make critical data more visible. For example, a field can be given a different background color when a record requires attention.
-
Customizing sections and tabs
Developers can adjust the appearance of form sections by changing colors, borders, font sizes, and spacing. This can help separate logical areas of a form and make complex forms easier for users to navigate.
-
Modifying the subgrid appearance
CSS can be used to customize subgrid elements, such as hiding unnecessary action icons, adjusting row styling, or emphasizing specific records. Since subgrids load asynchronously, CSS selectors are often more reliable than JavaScript-based modifications for purely visual changes.
-
Improving the user guidance
Visual indicators can be added to help users understand the purpose of fields or sections. For example, required information, warnings, or important business conditions can be emphasized through styling.
-
Applying the company’s branding
Custom colors, fonts, and visual elements can help align CRM forms with company branding standards.
When creating CSS selectors, it is recommended to target elements as specifically as possible. Using unique field IDs, subgrid IDs, or custom classes reduces the risk of unintentionally affecting other parts of the form. Avoid relying heavily on automatically generated Microsoft internal class names because these may change after Dynamics 365 updates.
Before deploying CSS customizations to a production environment, test them with different browsers, security roles, form configurations, and major Dynamics 365 releases to ensure consistent behavior.
Applying Custom CSS to Dynamics CRM Forms
To apply custom CSS to D365 CRM forms, it is necessary to go through the procedures offered below.
To create a Web Resource for JavaScript, take these actions:
-
Go to the “Settings > Customizations > Customize the System”.
-
Click on the “Web Resources”.
-
Click on the “New” to create a new web resource.
-
Set the Name.
-
Display the "Name" and the "Description" fields.
-
Opt JavaScript (JScript) as the type.
-
Add one of the given below JavaScript codes to embed the CSS:
If you want to use the static CSS from the external CSS file:
let loadCustomCSS = function () { let link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'here path of CSS file'; link.media = 'all'; document.getElementsByTagName('head')[0].appendChild(link); };If you want to use the inline CSS:
let loadCustomCSS = function () { let style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` /* Here, your custom CSS */ `; document.getElementsByTagName('head')[0].appendChild(style); }; -
Save the web resource and publish it.
To add the JavaScript Web Resource to the form where you want to apply the custom CSS, perform the following:
-
Proceed to the “Settings > Customizations > Customize the System”.
-
Choose the entity you want to customize.
-
Open the form editor for the desired form.
-
Append the "Form Libraries”. For this, in the form editor, click on the "Form Properties”. Under the "Form Libraries”, click on the “Add” and select the JavaScript web resource you have produced.
-
Add the “Onload Event”. For this, under the “Event Handlers”, select the “Form Onload”. Click on the “Add” and pick the function “loadCustomCSS” from the JavaScript web resource. Make certain the “Enabled” is checked.
-
Save the form and publish the customizations.
Examples of Using CSS in Subgrids
One common drawback of customizing subgrids with JavaScript is the necessity to add a timeout until the subgrid is loaded. This action is compulsory because subgrids are loaded asynchronously after the main form. However, no such delay is necessary for CSS changes, which is a significant benefit. We can apply CSS before the subgrids load, and it will work just fine.
To easily hide the “Delete” button for each record in a subgrid, you can use this code:
let loadCustomCSS = function () {
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `#SubgridId .ms-crm-ImageStrip-deleteButtonBin
{
display: none !important;
}`;
document.getElementsByTagName('head')[0].appendChild(style);
};

! Note. You can be more flexible by incorporating conditions based on different criteria.
To hide the delete button for a specific record by using its recordId (GUID), use such a code:
let loadCustomCSS = function () {
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `tr[oid="{77fb6b61-8818-4c60-b8c9-dfb63f17fffa}"] img
{
display: none !important;
}`;
document.getElementsByTagName('head')[0].appendChild(style);
};
In this case, we target the row (tr) with the attribute “oid” that matches the specific recordId (GUID).
Prettify Form Elements
To receive a prettify form element, you may utilize this code:
let loadCustomCSS = function () {
let style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `#address1_line2_cl
{
background-color: green !important;
color: black !important;
font-size: 20px !important;
font-weight: bold !important;
}`;
document.getElementsByTagName('head')[0].appendChild(style);
};

Conclusion
Custom CSS can be loaded into Dynamics CRM forms, allowing you to style the interface, customize the elements easily, and integrate with your logic. You have seen a simple and effective way to hide elements in subgrids using custom CSS, which is particularly useful given their asynchronous loading.
Frequently Asked Questions
Microsoft Dynamics 365 CRM does not provide a direct option to add custom CSS to forms. To apply styling changes, you need to create a JavaScript web resource that loads either an external CSS file or inline CSS and then attach it to the form’s OnLoad event.
Custom CSS through JavaScript web resources is a customization approach that can modify the appearance of CRM forms. However, since it relies on the underlying HTML structure and CSS classes, changes in future Dynamics 365 updates may affect how custom styles behave. Always test customizations after platform updates.
In Dynamics 365 model-driven apps, there is no supported way to directly add custom CSS to standard components such as forms, views, dashboards, grids, or command bars. For these areas, Microsoft recommends using supported customization options like form configuration, themes, business rules, custom pages, and PCF controls.
Custom CSS is supported in:
-
Power Pages (Dynamics 365 portals)
CSS files can be added through Web Files, Portal Management, or Power Pages Design Studio to customize pages, forms, lists, buttons, and layouts.
-
Custom pages in model-driven apps
CSS, HTML, and JavaScript can be used where supported.
-
Power Apps Component Framework controls
Developers can use CSS to style custom components.
It is also reasonable to avoid relying on CSS changes that modify internal Dynamics 365 elements, as updates may affect unsupported customizations.
-
Yes, custom CSS can be used to hide specific interface elements, such as delete buttons in subgrids or modify the appearance of form fields. By targeting specific CSS selectors, subgrid IDs, or record attributes, you can control the visibility and styling of selected elements.
Yes, JavaScript is typically required because Dynamics 365 CRM forms do not allow direct CSS file uploads for form styling. JavaScript web resources are used to dynamically inject CSS into the form when it loads, enabling custom design changes across CRM components.
Related Content
UDS blog articles:
