If I run the code below, my background does not turn red (nothing turns red). I am probably misusing the ‘body’ tag, but I do not know how to use it differently.
Nowhere in the Python code is referred to the ‘body’ tag. Can someone explain to me why my CSS ‘body’ styling is not applied while it is applied in the example? Also, I would like to know what I should do to make sure my app uses the styling in the defined CSS ‘body’ tag (in the case of the example below, the background should turn red).
import dash
import dash_html_components as html
import dash_core_components as dcc
Thanks for you reply, russellthehippo. However, your answer is not exactly what I am looking for.
I understand how you can assign a certain styling to a certain Div HTML-element in the way you demonstrate. However, I am working together with a front-end developer that just knows HTML and CSS. She is wondering how to apply a general page styling as one would by using the ‘body’ tag in HTML/CSS.
When you assign your layout to app.layout, it gets injected into a simple HTML template by Dash. In particular, everything you define in your layout will end up in the <body> of this simple template, so you can still write some custom CSS to add styles to the body which will get applied to everything in your layout unless it’s overridden by a more specific selector.
See the section “Customizing Dash’s HTML Index Template” here for more details on what the template is by default, and how to change it if you like.
See the section “Adding Your Own CSS and JavaScript to Dash Apps” at the same link for details on how to link an external stylesheet.