Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-99402

Custom CSSs are not applied for Globally or for Spaces using @import in the Stylesheet

XMLWordPrintable

      Issue Summary

      From Confluence 9.1 onwards, custom CSS applied using @import is being ignored. This affects the CSS from an external URL and CSS attached to a Confluence page.

      Steps to Reproduce

      1. Create a Confluence instance for any of the affected versions (>= 9.1).

      2. In the Global Stylsheet (General Config > Stylesheet) or space's Stylesheet (Space Tools > Look and Feel > Stylesheet), enter:

      @import url("<any external .css>");

      or

      @import url("<Confluence attachment URL containing CSS>")
      

      3. Load a page from this space

      4. In the developer tools, on the source tab, notice that the external .CSS is not mentioned

      Expected Results

      The CSS provided in the Stylesheet should be applied Globally or to the Space.

      Actual Results

      The CSS is ignored and not applied Globally or to the Space.

      Workaround

      A workaround is possible if we manually change the custom-css.vm file to prioritize $style attributes:

      1. Navigate to <install-folder>/confluence/styles
      2. Move the "Custom styles" section in the file custom-css.vm so that it is above the "### CUSTOM SITE LOGOS", like this:
        #disableAntiXss()
        
        ## Custom styles for Confluence (included for all themes by default)
        $style
        ## End custom styles for Confluence
        
        ### CUSTOM SITE LOGOS 
        .aui-header .aui-header-logo img {
         content: var(--confluence-custom-logo-content); 
        } 
        
      3. Save this change and restart Confluence

      Please take note of this manual change to Confluence's install files. Until a fixed version is released, you will need to reapply this change every time you upgrade your Confluence instance.

              5e496a614b63 Diclehan Erdal
              6444c12a624d B Cavalcante
              Votes:
              3 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: