Custom Common CSS and JavaScript

To change the color of Accept All or Reject All cookie button on the banner

  1. Navigate to Cookie Consent > Setup > Templates.
  2. Click the link in the Name column for the template that you want to edit.
  3. 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;
}
  1. Click the Apply Custom CSS button.
  2. 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

  1. Download the transparent .png file.
  2. Navigate to Cookie Consent > Setup > Templates.
  3. Click the link in the Template Name column for the template that you want to edit.
  4. Select Preference Center > Styling > Button Logo.
  5. Click the Upload button and select the file.
  6. 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.

  1. 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.

  1. Click the Apply Custom CSS button.
  2. 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

  1. Download the transparent .png file.
  2. Navigate to Cookie Consent > Setup > Templates.
  3. Click the link in the Template Name column for the template that you want to edit.
  4. Select Preference Center > Styling > Button Logo.
  5. Click the Upload button and select the file.
  6. 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.

  1. 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.

  1. Click the Apply Custom CSS button.
  2. Click the Save Template button. For the changes to reflect on your site, the respective domain's production or testing script must be republished.
  3. Navigate to Cookie Consent > Integration > Scripts.
  4. Click the link in the Name column for the script that you want to publish.
  5. 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:

  1. Navigate to Cookie Consent > Setup > Templates.
  2. Click the link in the Template Name column for the template that you want to edit.
  3. 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;
  1. Click the Apply Custom CSS button.
  2. 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

  1. Navigate to Cookie Consent > Setup > Templates.
  2. Click the link in the Name column for the template that you want to edit.
  3. 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;
}
  1. Click the Apply Custom CSS button.
  2. 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

  1. Navigate to Cookie Consent > Setup > Templates.
  2. Click the link in the Name column for the template that you want to edit.
  3. 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

  1. Navigate to Cookie Consent > Setup > Templates.
  2. Click the link in the Name column for the template that you want to edit.
  3. 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;
}
  1. Click the Apply Custom CSS button.
  2. 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 nameLocationDescriptionMulti Page templateEnhanced templateOriginal template
ot-confirmation-updateConfirmationBlock visible after preferences are updatedāŒāŒāœ…
ot-confirmation-update-headerConfirmationHeader block for updated preferences confirmationāŒāŒāœ…
ot-confirmation-update-descriptionConfirmationDescription block for updated preferences confirmationāŒāŒāœ…
ot-confirmation-unsubscribeConfirmationBlock visible after unsubscribe all is triggeredāŒāŒāœ…
ot-confirmation-unsubscribe-headerConfirmationHeader block for unsubscribe allāŒāŒāœ…
ot-confirmation-description-descriptionConfirmationDescription block for unsubscribe allāŒāŒāœ…
ot-loginLoginMain container for the login pageāœ…āœ…āœ…
ot-login-missingLoginBlock displayed when PC is accessed without an Idāœ…āœ…āœ…
ot-login-logoLoginImage tag showing the branding logoāœ…āœ…āœ…
ot-login-headerLoginPreferences Login Headline elementāœ…āœ…āœ…
ot-login-spinnerLoginSpinner visible when login page is loadingāœ…āœ…āœ…
ot-login-formLoginLogin form elementāœ…āœ…āœ…
ot-login-request-sentLoginBlock visible after the login email request has been sentāœ…āœ…āœ…
ot-login-poweredLoginPowered by OT logoāœ…āœ…āœ…
ot-preference-headerPreference FormTop header seen when logged ināœ…āœ…āœ…
ot-preference-spinnerPreference FormSpinner shown when preference center is being loadedāœ…āœ…āœ…
ot-preference-containerPreference FormContainer block for preference form and buttonsāœ…āœ…āœ…
ot-preference-loading-errorPreference FormBlock containing "Sorry, we cannot show your preferences..." messageāœ…āœ…āœ…
ot-preference-titlePreference FormPreference center titleāœ…āœ…āœ…
ot-preference-welcome-messagePreference FormWelcome message block below the title and above the formāŒāœ…āœ…
ot-preference-sidebarPreference FormNavigation sidebarāœ…āœ…āŒ
ot-preference-sidebar-pagePreference FormNavigation sidebar main menuāœ…āŒāŒ
ot-preference-sidebar-sectionPreference FormNavigation sidebar sub menuāœ…āŒāŒ
ot-preference-purposesPreference FormPurposes containerāŒāœ…āœ…
ot-preference-purposePreference FormPurpose-level blockāœ…āœ…āœ…
ot-preference-purpose-form-elementPreference FormBlock with a purpose name checkboxāŒāŒāœ…
ot-preference-purpose-form-checkboxPreference FormPurpose checkbox itselfāŒāŒāœ…
ot-preference-purpose-togglePreference FormPurpose toggle itselfāœ…āœ…āŒ
ot-preference-purpose-descriptionPreference FormPurpose description shown below the ot-preference-purpose-form-element (removed)āŒāŒāŒ
ot-preference-topicsPreference FormBlock containing purpose topicsāœ…āœ…āœ…
ot-preference-topicPreference FormSingle purpose topicāœ…āœ…āœ…
ot-preference-topic-checkboxPreference FormSingle purpose topic checkboxāœ…āœ…āœ…
ot-preference-customPreference FormSingle purpose preferenceāœ…āœ…āŒ
ot-preference-custom-optionPreference FormSingle purpose preference optionāŒāœ…āŒ
ot-preference-custom-option-buttonPreference FormSingle purpose preference button optionāœ…āŒāŒ
ot-preference-custom-option-checkboxPreference FormSingle purpose preference checkbox optionāœ…āŒāŒ
ot-preference-actionsPreference FormAction bar displayed below the form with Save and Unsubscribe All buttonsāœ…āœ…āœ…
ot-preference-actions-unsubscribePreference FormUnsubscribe All buttonāŒāŒāœ…
ot-preference-actions-undoPreference FormUndo Changes buttonāœ…āœ…āŒ
ot-preference-actions-updatePreference FormUpdate Preferences buttonāœ…āœ…āœ…
ot-preference-settingsPreference FormSubscription Settings sectionāœ…āœ…āŒ
ot-preference-settings-unsubscribePreference FormSubscription Settings unsubscribe settingāœ…āœ…āŒ
ot-preference-settings-notificationsPreference FormSubscription Settings notification settingāœ…āœ…āŒ
ot-preference-sectionPreference FormSection containerāœ…āŒāŒ
ot-preference-data-elementPreference FormData element containerāœ…āŒāŒ
ot-preference-text-blockPreference FormText block containerāœ…āŒāŒ
ot-section-identifierPreference FormData subject identifier expand collapseāœ…āŒāŒ
ot-preference-custom-option-attentionPreference FormPurpose preferences required alert while moving to the next pageāœ…āŒāŒ
ot-preference-sidebar-attentionPreference FormSidebar section alert for required purpose preferences while moving to next pageāœ…āŒāŒ
ot-preference-data-element-multi-selectPreference FormData element multi selection inputāœ…āŒāŒ
ot-preference-data-element-single-selectPreference FormData element single selection inputāœ…āŒāŒ
ot-preference-data-element-emailPreference FormData element email inputāœ…āŒāŒ
ot-preference-data-element-numberPreference FormData element number inputāœ…āŒāŒ
ot-preference-data-element-datePreference FormData element date inputāœ…āŒāŒ
ot-preference-data-element-countryPreference FormData element country inputāœ…āŒāŒ
ot-preference-data-element-statePreference FormData element state inputāœ…āŒāŒ
ot-preference-data-element-phone-numberPreference FormData element phone number inputāœ…āŒāŒ
ot-preference-data-element-phone-codePreference FormData element phone code inputāœ…āŒāŒ
ot-preference-data-element-inputPreference FormData element inputāœ…āŒāŒ
ot-preference-pagePreference FormMulti page containerāœ…āŒāŒ
ot-preference-section-containerPreference FormSection containerāœ…āŒāŒ
ot-preference-settings-containerPreference FormSubscription settings section containerāœ…āŒāŒ
ot-preference-sidebar-page-itemPreference FormPage sidebar blockāœ…āŒāŒ
ot-preference-section-headerPreference FormSection header blockāœ…āŒāŒ
ot-preference-section-itemsPreference FormAll sections containerāœ…āŒāŒ
ot-preference-sidebar-section-itemPreference FormSection sidebar blockāœ…āŒāŒ
ot-profile-containerProfile FormContainer block for profile formāŒāœ…āŒ
ot-profile-titleProfile FormProfile titleāŒāœ…āŒ
ot-profile-data-elements-containerProfile FormContainer block for the data elementsāŒāœ…āŒ
ot-profile-data-element-inputProfile FormData element inputāŒāœ…āŒ
ot-profile-action-undoProfile FormUndo Changes buttonāŒāœ…āŒ
ot-profile-action-updateProfile FormUpdate buttonāŒāœ…āŒ