Custom Common CSS and JavaScript
To change the color of Accept All or Reject All cookie button on the banner
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Name column for the template that you want to edit.
- In your template's Banner Custom CSS section (Cookie Consent > Templates > Banner > Styling > Custom CSS), add the following:
/* Accept button */
button#onetrust-accept-btn-handler {
background-color: green !important;
}
/* Reject button */
button#onetrust-reject-all-handler {
background-color: red !important;
}
- Click the Apply Custom CSS button.
- Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
To customize the persistent Cookie Settings button
To change the color

- Download the transparent .png file.
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Template Name column for the template that you want to edit.
- Select Preference Center > Styling > Button Logo.
- Click the Upload button and select the file.
- In your template's Preference Center Custom CSS section (Cookie Consent > Setup > Templates > Preference Center > Styling > Custom CSS), add the following:
#ot-sdk-btn-floating .ot-floating-button__front { background-color: #140b75 !important; }
Ensure that the
!important
property is not missed from the CSS above or it will default to light blue color.
- Update the HEX value
#140b75
above to the HEX color code you want on the page.
You can use the built-in Colour picker functionality typing "hex colour picker" on Google.
- Click the Apply Custom CSS button.
- Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
For the changes to reflect on your site, the respective domain's production or testing script must be republished.
To change the cookie icon to a shield icon adding a custom color

- Download the transparent .png file.
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Template Name column for the template that you want to edit.
- Select Preference Center > Styling > Button Logo.
- Click the Upload button and select the file.
- In your template's Preference Center Custom CSS section (Cookie Consent > Setup > Templates > Preference Center > Styling > Custom CSS), add the following:
#ot-sdk-btn-floating .ot-floating-button__front { background-color: #140b75 !important; box-shadow: 5px 5px 8px 0 rgb(0 0 0 / 20%) !important; border-radius: 10px !important; }
Ensure that the
!important
property is not missed from the CSS above or it will default to light blue color and be circular instead of a rounded-edged square.
- Update the HEX value
#140b75
above to the HEX color code you want on the page.
You can use the built-in Colour picker functionality typing "hex colour picker" on Google.
For more information, see Customizing the Preference Center Template.
- Click the Apply Custom CSS button.
- Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
- Navigate to Cookie Consent > Integration > Scripts.
- Click the link in the Name column for the script that you want to publish.
- Click the Publish Test or the Publish Production button to commit the changes.
For more information on script settings and configuration, see Publishing and Implementing Cookie Consent Scripts.
To change the contrast ratio of background color on banner buttons
OneTrust banner buttons' text-to-background colour contrast should be a minimum of 4.5:1 when focused or hovered over (default behavior is to reduce the opacity to 0.9). Follow the steps below to ensure that the required contrast ratio is met:
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Template Name column for the template that you want to edit.
- In your template's Banner Custom CSS section (Cookie Consent > Setup > Templates > Banner > Styling > Custom CSS), add the following to override the opacity settings:
#onetrust-banner-sdk .ot-sdk-button:hover,
#onetrust-banner-sdk :not(.ot-leg-btn-container)>button:not(.ot-link-btn):hover,
#onetrust-banner-sdk :not(.ot-leg-btn-container)>button:not(.ot-link-btn):focus,
#onetrust-pc-sdk .ot-sdk-button:hover,
#onetrust-pc-sdk :not(.ot-leg-btn-container)>button:not(.ot-link-btn):hover,
#onetrust-pc-sdk :not(.ot-leg-btn-container)>button:not(.ot-link-btn):focus,
#ot-sdk-cookie-policy .ot-sdk-button:hover,
#ot-sdk-cookie-policy :not(.ot-leg-btn-container)>button:not(.ot-link-btn):hover,
#ot-sdk-cookie-policy :not(.ot-leg-btn-container)>button:not(.ot-link-btn):focus {
opacity: 1;
- Click the Apply Custom CSS button.
- Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
This will cancel the buttons' opacity settings when focused or hovered to match the applied coloring configurations in the template styling section. Please note that the code above is for example purposes only, and you will need to manage and maintain it or make any further edits.
Extra CSS settings may be required to add extra coloring configurations for buttons when hovered/focused if needed.
For more information on template configurations and banner publication, see Customizing the Banner Template and Publishing and Implementing Cookie Consent Scripts.
To change the color of the Allow All button on the preference center
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Name column for the template that you want to edit.
- In your template's preference center Custom CSS section (Cookie Consent > Setup > Templates > Preference Center > Styling > Custom CSS), add the following:
button#accept-recommended-btn-handler {
background-color: green !important;
}
- Click the Apply Custom CSS button.
- Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
To change the color of the Confirm My Choices button on the preference center
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Name column for the template that you want to edit.
- In your template's preference center Custom CSS section (Cookie Consent > Setup > Templates > Preference Center > Styling > Custom CSS), add the following:
button.save-preference-btn-handler.onetrust-close-btn-handler {
background-color: blue !important;
}
To remove the OneTrust logo from the preference center
- Navigate to Cookie Consent > Setup > Templates.
- Click the link in the Name column for the template that you want to edit.
- In your template's preference center Custom CSS section (Cookie Consent > Templates > Preference Center > Styling > Custom CSS), add the following:
#onetrust-pc-sdk .ot-pc-footer-logo a {
display: none;
}
#onetrust-pc-sdk .ot-pc-logo {
display: none;
}
- Click the Apply Custom CSS button.
- Click the Save Template button.
To customize preference centers using Custom CSS
You can customize the appearance of your preference center with custom CSS. Your CSS customizations will be applied on top of the existing layout provided by OneTrust. The following Custom CSS classes for preference centers table details the CSS classes that can be adjusted for each respective preference center template type.
CSS files for the Original, Enhanced, and Multi Page preference center templates can be downloaded here: Preference Center CSS Files.
Custom CSS classes for preference centers
Class name | Location | Description | Multi Page template | Enhanced template | Original template |
---|---|---|---|---|---|
ot-confirmation-update | Confirmation | Block visible after preferences are updated | ❌ | ❌ | ✅ |
ot-confirmation-update-header | Confirmation | Header block for updated preferences confirmation | ❌ | ❌ | ✅ |
ot-confirmation-update-description | Confirmation | Description block for updated preferences confirmation | ❌ | ❌ | ✅ |
ot-confirmation-unsubscribe | Confirmation | Block visible after unsubscribe all is triggered | ❌ | ❌ | ✅ |
ot-confirmation-unsubscribe-header | Confirmation | Header block for unsubscribe all | ❌ | ❌ | ✅ |
ot-confirmation-description-description | Confirmation | Description block for unsubscribe all | ❌ | ❌ | ✅ |
ot-login | Login | Main container for the login page | ✅ | ✅ | ✅ |
ot-login-missing | Login | Block displayed when PC is accessed without an Id | ✅ | ✅ | ✅ |
ot-login-logo | Login | Image tag showing the branding logo | ✅ | ✅ | ✅ |
ot-login-header | Login | Preferences Login Headline element | ✅ | ✅ | ✅ |
ot-login-spinner | Login | Spinner visible when login page is loading | ✅ | ✅ | ✅ |
ot-login-form | Login | Login form element | ✅ | ✅ | ✅ |
ot-login-request-sent | Login | Block visible after the login email request has been sent | ✅ | ✅ | ✅ |
ot-login-powered | Login | Powered by OT logo | ✅ | ✅ | ✅ |
ot-preference-header | Preference Form | Top header seen when logged in | ✅ | ✅ | ✅ |
ot-preference-spinner | Preference Form | Spinner shown when preference center is being loaded | ✅ | ✅ | ✅ |
ot-preference-container | Preference Form | Container block for preference form and buttons | ✅ | ✅ | ✅ |
ot-preference-loading-error | Preference Form | Block containing "Sorry, we cannot show your preferences..." message | ✅ | ✅ | ✅ |
ot-preference-title | Preference Form | Preference center title | ✅ | ✅ | ✅ |
ot-preference-welcome-message | Preference Form | Welcome message block below the title and above the form | ❌ | ✅ | ✅ |
ot-preference-sidebar | Preference Form | Navigation sidebar | ✅ | ✅ | ❌ |
ot-preference-sidebar-page | Preference Form | Navigation sidebar main menu | ✅ | ❌ | ❌ |
ot-preference-sidebar-section | Preference Form | Navigation sidebar sub menu | ✅ | ❌ | ❌ |
ot-preference-purposes | Preference Form | Purposes container | ❌ | ✅ | ✅ |
ot-preference-purpose | Preference Form | Purpose-level block | ✅ | ✅ | ✅ |
ot-preference-purpose-form-element | Preference Form | Block with a purpose name checkbox | ❌ | ❌ | ✅ |
ot-preference-purpose-form-checkbox | Preference Form | Purpose checkbox itself | ❌ | ❌ | ✅ |
ot-preference-purpose-toggle | Preference Form | Purpose toggle itself | ✅ | ✅ | ❌ |
ot-preference-purpose-description | Preference Form | Purpose description shown below the ot-preference-purpose-form-element (removed) | ❌ | ❌ | ❌ |
ot-preference-topics | Preference Form | Block containing purpose topics | ✅ | ✅ | ✅ |
ot-preference-topic | Preference Form | Single purpose topic | ✅ | ✅ | ✅ |
ot-preference-topic-checkbox | Preference Form | Single purpose topic checkbox | ✅ | ✅ | ✅ |
ot-preference-custom | Preference Form | Single purpose preference | ✅ | ✅ | ❌ |
ot-preference-custom-option | Preference Form | Single purpose preference option | ❌ | ✅ | ❌ |
ot-preference-custom-option-button | Preference Form | Single purpose preference button option | ✅ | ❌ | ❌ |
ot-preference-custom-option-checkbox | Preference Form | Single purpose preference checkbox option | ✅ | ❌ | ❌ |
ot-preference-actions | Preference Form | Action bar displayed below the form with Save and Unsubscribe All buttons | ✅ | ✅ | ✅ |
ot-preference-actions-unsubscribe | Preference Form | Unsubscribe All button | ❌ | ❌ | ✅ |
ot-preference-actions-undo | Preference Form | Undo Changes button | ✅ | ✅ | ❌ |
ot-preference-actions-update | Preference Form | Update Preferences button | ✅ | ✅ | ✅ |
ot-preference-settings | Preference Form | Subscription Settings section | ✅ | ✅ | ❌ |
ot-preference-settings-unsubscribe | Preference Form | Subscription Settings unsubscribe setting | ✅ | ✅ | ❌ |
ot-preference-settings-notifications | Preference Form | Subscription Settings notification setting | ✅ | ✅ | ❌ |
ot-preference-section | Preference Form | Section container | ✅ | ❌ | ❌ |
ot-preference-data-element | Preference Form | Data element container | ✅ | ❌ | ❌ |
ot-preference-text-block | Preference Form | Text block container | ✅ | ❌ | ❌ |
ot-section-identifier | Preference Form | Data subject identifier expand collapse | ✅ | ❌ | ❌ |
ot-preference-custom-option-attention | Preference Form | Purpose preferences required alert while moving to the next page | ✅ | ❌ | ❌ |
ot-preference-sidebar-attention | Preference Form | Sidebar section alert for required purpose preferences while moving to next page | ✅ | ❌ | ❌ |
ot-preference-data-element-multi-select | Preference Form | Data element multi selection input | ✅ | ❌ | ❌ |
ot-preference-data-element-single-select | Preference Form | Data element single selection input | ✅ | ❌ | ❌ |
ot-preference-data-element-email | Preference Form | Data element email input | ✅ | ❌ | ❌ |
ot-preference-data-element-number | Preference Form | Data element number input | ✅ | ❌ | ❌ |
ot-preference-data-element-date | Preference Form | Data element date input | ✅ | ❌ | ❌ |
ot-preference-data-element-country | Preference Form | Data element country input | ✅ | ❌ | ❌ |
ot-preference-data-element-state | Preference Form | Data element state input | ✅ | ❌ | ❌ |
ot-preference-data-element-phone-number | Preference Form | Data element phone number input | ✅ | ❌ | ❌ |
ot-preference-data-element-phone-code | Preference Form | Data element phone code input | ✅ | ❌ | ❌ |
ot-preference-data-element-input | Preference Form | Data element input | ✅ | ❌ | ❌ |
ot-preference-page | Preference Form | Multi page container | ✅ | ❌ | ❌ |
ot-preference-section-container | Preference Form | Section container | ✅ | ❌ | ❌ |
ot-preference-settings-container | Preference Form | Subscription settings section container | ✅ | ❌ | ❌ |
ot-preference-sidebar-page-item | Preference Form | Page sidebar block | ✅ | ❌ | ❌ |
ot-preference-section-header | Preference Form | Section header block | ✅ | ❌ | ❌ |
ot-preference-section-items | Preference Form | All sections container | ✅ | ❌ | ❌ |
ot-preference-sidebar-section-item | Preference Form | Section sidebar block | ✅ | ❌ | ❌ |
ot-profile-container | Profile Form | Container block for profile form | ❌ | ✅ | ❌ |
ot-profile-title | Profile Form | Profile title | ❌ | ✅ | ❌ |
ot-profile-data-elements-container | Profile Form | Container block for the data elements | ❌ | ✅ | ❌ |
ot-profile-data-element-input | Profile Form | Data element input | ❌ | ✅ | ❌ |
ot-profile-action-undo | Profile Form | Undo Changes button | ❌ | ✅ | ❌ |
ot-profile-action-update | Profile Form | Update button | ❌ | ✅ | ❌ |
Updated 3 days ago