[SOLVED] CSS class styles are not applied to {% block content %} | SoloLearn: Learn to code for FREE!


[SOLVED] CSS class styles are not applied to {% block content %}

I have a block content in my html template in a Django project, I loaded the static folder, the styles of the CSS are all applied to the page, the problem is in the div that contains the block content which is my home template, adding a boostrap class works, adding a style inside my div tag itself also works, yet the class styling in my CSS file is not working.. <div class="contents"> {% block content %}{% endblock %} </div> div .contents { margin-top: 40px; } Why is that happening?

4/22/2020 7:32:47 PM

Ali Abdelhady

2 Answers

New Answer


Well, i assume you don't forget to wrap css in <style> tag... Also why div .contents? Just the class selector will do... Also there is big differe ce between div.contents and div .contents... First one is "div that has class contetns" and the second is "all elements within the div that have class contents"


Aleksandar Stevanovic div.contents works, it's actually that extra space, thanks for the info I also removed the div...