# Add a CSS class to the DIVs of the fields of all forms

**URL:** <https://forum.djangoproject.com/t/add-a-css-class-to-the-divs-of-the-fields-of-all-forms/26970>\
**Category:** Templates & Frontend\
**Created:** [January 15, 2024, 12:10pm UTC](https://forum.djangoproject.com/t/add-a-css-class-to-the-divs-of-the-fields-of-all-forms/26970 "2024-01-15T12:10:18Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 16, 2024, 1:25pm UTC](https://forum.djangoproject.com/t/add-a-css-class-to-the-divs-of-the-fields-of-all-forms/26970/4 "2024-01-16T13:25:53Z")

</div>

Sorry - I was not attempting to answer _that_ portion of your question. But from what I’m seeing - no. There does not appear to be a “global default” that would apply to every field being rendered. I know you can change this on a per-field basis - but then you’d need to add this to every field definition on every form, and that’s _not_ my impression of what you’re looking for.

Side note: Actually, I would hold the opinion that overriding a template is less risky than modifying code. It’s not like there’s going to be other code dependent upon the behavior of that template.

But even _that_ may not be necessary. As I’m looking through the source trying to find an answer, I see where `BaseForm` has a `template_name_div` attribute - if you need to do this on a by-form basis, you could set that attribute for each form individually. If you want this for every form, you could create a Form subclass that has that attribute defined, then inherit all your forms from it.

---

_[View the full topic](https://forum.djangoproject.com/t/add-a-css-class-to-the-divs-of-the-fields-of-all-forms/26970)._
