# Margin being applied to both module and module wrapper

**URL:** <https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351>\
**Category:** CMS Development\
**Tags:** css\
**Created:** [March 5, 2025, 9:57am UTC](https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351 "2025-03-05T09:57:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajatnb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajatnb/32/104126_2.png) [@ajatnb](https://community.hubspot.com/u/ajatnb)\
**Post date:** [March 5, 2025, 9:57am UTC](https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351/1 "2025-03-05T09:57:44Z")

</div>

When adding a margin style to my custom module, the margin is also being added to the module wrapper. Why? What is happening here?

_fields.json_

```lia-code-sample
{
 "id": "module.styles.margin",
 "label": "Margin",
 "name": "margin",
 "type": "group",
 "children": [
 {
 "id": "module.styles.margin.top",
 "label": "Top",
 "name": "top",
 "type": "number",
 "display": "text",
 "suffix": "px",
 "min": -40,
 "max": 40,
 "step": 4,
 "default": 0
 }, {
 "id": "module.styles.margin.bottom",
 "label": "Bottom",
 "name": "bottom",
 "type": "number",
 "display": "text",
 "suffix": "px",
 "min": -40,
 "max": 40,
 "step": 4,
 "default": 0
 }
 ]
}

```

_module.html_

```lia-code-sample
{% require_css %}
 <style>
 {% scope_css %}
 .plain-text-module {
 margin-top: {{ module.styles.margin.top }}px;
 margin-bottom: {{ module.styles.margin.bottom }}px;
 }
 {% end_scope_css %}
 </style>
{% end_require_css %}

<div id="plain-text-module__{{ name }}" class="plain-text-module">
 {% text value="{{ module.text }}" %}
</div>

```

_Rendered HTML_

 ![Screenshot 2025-03-05 at 1.25.04 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/0/205f8816f33015221a814059be7e8d0ec7fe013b.png)

_Expected CSS_

- 

 ![Screenshot 2025-03-05 at 1.23.33 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/0/60289cc75d4b33b96b614ba165b66440f4c20f26.png)  
\*

_Unexpected CSS_

- 

 ![Screenshot 2025-03-05 at 1.35.18 AM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/a/ea3572570c7bfed23006127185913823d77fbf09.png)  
\*

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 5, 2025, 9:12pm UTC](https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351/2 "2025-03-05T21:12:13Z")

</div>

Hey, @ajatnb 👋 Have you already ruled out something like this?

```lia-code-sample
// Change from:
"id": "module.styles.margin",
"name": "margin",

// To:
"id": "module.styles.customMargin",
"name": "customMargin",

```

I’m not the best with styling, so some tweaking may be needed.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![melindagreen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/melindagreen/32/73804_2.png) [@melindagreen](https://community.hubspot.com/u/melindagreen)\
**Post date:** [March 5, 2025, 10:08pm UTC](https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351/3 "2025-03-05T22:08:22Z")

</div>

hi @ajatnb ,

in my experience, using dot notation in the field ID is representative of nesting. so this, to me, looks like you should have a field named “module,” with a child field “styles,” with a child field “margin,” with child fields “top” and “bottom.”  
if your fields.json code above is the entire file, try changing all three instances of “module.styles.margin” to something like “module\_styles\_margin” (a single term, no parent-child relationship implied) or and see if that makes a difference in how it’s rendered.  
your top and bottom fields would then have IDs module\_styles\_margin.top and module\_styles\_margin.bottom .  
also, i noticed that you have a suffix of “px” on your margin fields, and then you also add “px” in your HTML file. that may or may not be related.

---

<div class="post-metadata">

**Author:** ![ajatnb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajatnb/32/104126_2.png) [@ajatnb](https://community.hubspot.com/u/ajatnb)\
**Post date:** [March 6, 2025, 2:42am UTC](https://community.hubspot.com/t/margin-being-applied-to-both-module-and-module-wrapper/127351/4 "2025-03-06T02:42:05Z")

</div>

thank you, [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074). that does appear to work. it’s curious that i need that workaround.

thank you, too, @melindagreen, for your input. i did only include the relevant objects from my theme.json file. the nesting is set up correctly in the file itself. too, for reference, the suffix set in the json file is simply for display purposes in the content editor and has no effect on the numerical value of the field. the suffix is needed in the HTML to work properly. ([reference](https://developers.hubspot.com/docs/reference/cms/fields/module-theme-fields#number))
