# Creating a form with a background

**URL:** <https://community.hubspot.com/t/creating-a-form-with-a-background/42860>\
**Category:** CMS Development\
**Tags:** forms\
**Created:** [August 25, 2021, 10:01am UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860 "2021-08-25T10:01:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![borkacer](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@borkacer](https://community.hubspot.com/u/borkacer)\
**Post date:** [August 25, 2021, 10:01am UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860/1 "2021-08-25T10:01:20Z")

</div>

Hi community,

I have a very little experience with HTML and CSS, however I have been working in HubSpot enviroment for a little while, so I know something from trial and fail. So I want to create a form with an image as a background that spreads across the width of the page. The question would you approach this by creating a custom module with an embed form? If so, can anybody provide me with HTML and CSS of something similiar so I can go from there?

Here is a picture how it should look

 ![Screenshot 2021-08-25 115206.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/2/32d870cdf2fd16298b0a4a94af99768438ee6578.jpeg)  
How it should look

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 25, 2021, 10:14am UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860/2 "2021-08-25T10:14:53Z")

</div>

Hi!  
Are you using the design tools to create this element or Local Development?  
I can send you the HTML and CSS for this module but the fields are just as important.

---

<div class="post-metadata">

**Author:** ![borkacer](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@borkacer](https://community.hubspot.com/u/borkacer)\
**Post date:** [August 25, 2021, 10:34am UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860/3 "2021-08-25T10:34:21Z")

</div>

Hi Teun

Could you elaborate on the design tools and Local Developement, because I have no clue honestly. I kind of understand that the fields in a custom module are for changing/personalizing stuff in the website manager later on if I am not mistaken. As I said, I have no experience with this but I took on this task at work to see if I could do it.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 25, 2021, 10:53am UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860/4 "2021-08-25T10:53:50Z")

</div>

Hi!  
Here is a quick read on the structure of a module:

> **[Coding Custom Modules - HubSpot docs](https://developers.hubspot.com/docs/cms/reference/modules/files)**
>
> Custom modules are reusable components you can use across your website. Build them following best practices for speed, user experience and accessibility.

And here a quick explanation on how to create a module in the Design Tools:

> **[Create and edit modules in the design manager](https://knowledge.hubspot.com/design-manager/create-and-edit-modules)**
>
> Learn how to create and customize modules in HubSpot's Design Manager to enhance your blog, pages, or emails.

And here about Local Development:

> **[Install the HubSpot CLI - HubSpot docs](https://developers.hubspot.com/docs/developer-tooling/local-development/hubspot-cli/install-the-cli)**
>
> Learn how to get started with local development by installing the HubSpot CLI

For this module, I would start with creating a module through the Design Tools and invest in Local Development later on.  
If you need help with the HTML and CSS, please let me know.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 25, 2021, 6:03pm UTC](https://community.hubspot.com/t/creating-a-form-with-a-background/42860/5 "2021-08-25T18:03:27Z")

</div>

Hi @borkacer ,

So I’ll describe below how I would create this module. I’ll leave out any advanced options or styling, but this should get you going.  
**Step 1**  
Create a module in the ‘Design Tools’ (Marketing \> Files and templates \> Design tools) by clicking on the ‘File’ dropdown on the left side of the screen.

 ![Schermafbeelding 2021-08-25 om 19.28.50.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/1/1a152b29a0c30a873909d879557b91b49c91e8b9.png)

Select ‘Module’ in the popup that shows when you click ‘New file’.  
**Step 2**

Decide what templates you want to use your module in, and give it a recognizable name. You can set it as a ‘global’ module if you want the content to be the same for all pages. If not, select ‘local’ module.

 ![Schermafbeelding 2021-08-25 om 19.31.10.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/f/f630511eb39514f4348120e989ed33d6f0a1c593.png)

**Step 3**  
Determine the fields you need for this module. Based on your screenshot, I think we need the following:  
- Image (for the background, we will set this in the ‘Style Fields’ below the default ‘Fields’)  
- Form (for the form, duh)  
- Rich text (for the content)  
- Choice (for the position of the content (optional)) (Options: left / right)  
On the right side of the screen, click on the ‘Add field’ button and select the field types you need. Give them a recognizable name, so you can use that in the code.

You should now have the following fields:

 ![Schermafbeelding 2021-08-25 om 19.51.11.png](https://d2qpr2jzcazej7.cloudfront.net/original/1X/bccffcf96e4a0f5d437ca66a3c592448e8d461c6.png)

**Step 4**

Write the necessary HTML for this module. Below is a code snippet that gives you same basic HTML which should help you to create your module:

```lia-code-sample
{% require_css %}
<style>
 {% scope_css %}
 .form-with-content {
 {{ module.style.background.css }}
 }
 {% end_scope_css %} 
</style>
{% end_require_css %}

<section class="form-with-content">
 <div class="form-with-content__container">
 <div class="form-with-content __content form-with-content__ content--{{module.position}}">
 {{ module.content }} <!-- this will contain the content set through your 'Content' field -->
 </div>
 <div class="form-with-content__form">
 <!-- Below is the necessary HuBL for the form to show -->
 {% form
 form_to_use="{{ module.form.form_id }}"
 response_response_type="{{ module.form.response_type }}"
 response_message="{{ module.form.message }}"
 response_redirect_id="{{ module.form.redirect_id }}"
 response_redirect_url="{{module.form.redirect_url}}"
 %}
 </div>
 </div>
</section>

```

**Step 5**  
Write the necessary CSS for the module. I used the Style fields to generate some basic inline styling for the background image. If you want to style the background image yourself, please let me know. Below is some basic styling:

```lia-code-sample
.form-with-content {
 padding: 3rem 0; /* Change this if needed */
}

.form-with-content__container {
 display: flex;
 flex-wrap: wrap;
 align-items: flex-start;
 max-width: 1200px; /* Change this */
 margin: 0 auto;
}

.form-with-content__content,
.form-with-content__form {
 display: block;
 box-sizing: border-box;
 width: 50%;
}

.form-with-content__content {
 padding-right: 3rem; /* Change this */
 /* Add some more styling for the typography if needed */
}

.form-with-content__content--right {
 order: 2; /* Styling based on the 'position' field */
 padding-right: 0;
 padding-left: 3rem; /* Change this if needed */
}

/* styling for mobile, change the pixels if needed */
@media screen and max-width(767px) {
 .form-with-content__content,
 .form-with-content__form {
 width: 100%;
 }

 .form-with-content__content {
 padding-right: 0;
 padding-left: 0;
 padding-bottom: 2rem; /* Change this if needed */
 }

 .form-with-content__content--right {
 padding-bottom: 0;
 padding-top: 2rem; /* Assuming the content is at the bottom on mobile devices */
 }
}

```

Ofcourse this needs some more work, but this should get you going.
