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βŒβœ…βŒ