Stylesheets And JavaScript
Information on working with stylesheets and JavaScript in Umbraco, including bundling & minification.
Stylesheets in the Backoffice
You can create and edit stylesheets in the Stylesheets folder in the Settings section of the Backoffice.
![Creating a new stylesheet](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252F9fQE5vFjE0hKgpao7dUb%252Fimage.png%3Falt%3Dmedia%26token%3D81988677-2569-4eb2-a252-a5377638312f&width=768&dpr=4&quality=100&sign=c8bff819&sv=1)
In the Create menu, these options are available:
Stylesheet file (for use in templates/views)
Rich Text Editor stylesheet file (for use in Rich Text Editor)
Folder (for keeping stylesheets organized)
It is currently not possible to use any CSS preprocessor (such as Syntactically Awesome Style Sheets (SASS)) in the backoffice.
After creating a new stylesheet, you would work with it as you would with templates or JavaScript files - using the built-in backoffice text editor. When you're working with stylesheets, you also have access to the Rich Text Editor, which allows you to create CSS styles and get a real-time preview.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-c09094a7d33b2b9d9a4aad00c3d187635b2b190e%252F2-rte-editor.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=9aff4208&sv=1)
The rules you create in the Rich Text Editor section will carry over to the Code tab.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-2e2c1713de4829bc3121e39ccc1ff0fcc8c00233%252F3-rte-editor-p2.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=55c38a11&sv=1)
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-55f70239042c85fac65fab122a525322873caa43%252F3-rte-editor-p3.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=8d7b9f68&sv=1)
To reference your newly included stylesheet in a template file, navigate to Templates, pick the template you like (css files are usually referenced in the layout or home templates) and link to it with the link
tag.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-9a9a2d7f9d2b4e7269bb23b8f86c0488d70002c4%252F4-link-css-v9.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=23a2bdc5&sv=1)
By default, the stylesheets will be saved in the wwwroot/css
folder in the solution. To reference them you can use either of the methods used in the above screenshot.
or
With the stylesheet referenced, you will be able to style the template file with the rules and classes defined in the stylesheet.
Your stylesheets can be used in Rich Text Editors (datatype) as well - please see the Rich Text Editor documentation for more information.
If your RTE is styled differently on the frontend of the site, the backoffice styling might be getting overwritten by other stylesheets you have included.
JavaScript files in the Backoffice
To create and edit JavaScript files in the Backoffice, head on over to the Scripts folder in the Settings section of the Backoffice.
![Creating a new JavaScript](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252FCjNxlUfS3sgoEEeixMXS%252Fimage.png%3Falt%3Dmedia%26token%3D4af099c8-3dec-4202-8caa-f72f7ab51698&width=768&dpr=4&quality=100&sign=47643930&sv=1)
From here you can add a new JavaScript file, or a new folder.
Add a new JavaScript file and write your code:
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-000ee142a1be72cf182b7c2cc4657a6e7d383a8b%252F9-myscript.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=db02a057&sv=1)
Then, navigate to the template where you would like to include your JS file.
![](https://docs.umbraco.com/~gitbook/image?url=https%3A%2F%2F3701346516-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FG1Byxw7XfiZAj8zDMCTD%252Fuploads%252Fgit-blob-14202a63874a8b782d5d0bb5acb2ad29af4bfc1f%252F10-reference-script-v9.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=f67fe89&sv=1)
By default all JavaScript files will be stored in the wwwroot/scripts
folder in the solution.
If you are working locally, you can create CSS and JS files outside of the Backoffice - as long as they are placed in appropriate folders (css
and scripts
), they will show up in the Backoffice when you click ... next to the Stylesheets folder and then select Reload.
Last updated