Tips for using HTML and CSS in your forms

In this document, we’ll show you how to use the HTML Code block and share with you some basic HTML and CSS tricks that you can use to customize your forms.

Please note that this is an advanced feature and does require knowledge of CSS and HTML. If you are not familiar with HTML or CSS, we recommend working with a member of your team who is. There are also several great resources out there where you can learn HTML and CSS such as this one.

HTML

The HTML block allows you to add text with embedded links to your inline form. You may want to use this if you wish to link contacts to a video or privacy policy page on your site. You can also format the text as well as its alignment in this specific block.

Please note that the HTML block can only be used on inline forms. Float box, floating bar, and modal forms do not have the option to add an HTML block.

Adding the HTML Code block to your form

To get started, simply drag and drop the “HTML Code” block to any place on your form. This block is located under the Fields > Standard:

HTML_code_block.png

To add your custom HTML, click that HTML Code block in your form. Once you do, you will be able to enter your code into the box on the right side of your screen:

add_html_code.png

Now you’re ready to add your own HTML to your form.

Basic HTML Code

You can use the following to add styling to the text in your HTML Code block.

Center text
Tags used: <center> </center>

In this example, we placed the text we wanted centered in between the two tags. This is how we set it up: 

<center>Send us your name and email to subscribe to our newsletter.</center>

center_text_html.png

Add line break
Tags used: <p> </p>

In this example, we added a link break between two sentences in our HTML block. This is how we set it up:

Send us your name and email to sign up for our newsletter. <p>Don't forget to add us to your contact list!</p>

Line_break_code.png
Bold Text
Tags used <b> </b>

In this example, we wanted to bold a sentence in our HTML block. This is how we set it up: 

Send us your name and email to sign up for our newsletter. <b>Don't forget to add us to your contact list!</b>

Bold_html.png

Underline text
Tags used <u> </u>

In this example, we wanted to underline a sentence in our HTML block. This is how we set it up:

Send us your name and email to sign up for our newsletter. <u>Don't forget to add us to your contact list!</u>

Underline_html.png

Add link
Tags used <a href> </a href>

In this example, we wanted to add a link to our privacy policy for subscribers to click on. This is how we set it up:

Send us your name and email to sign up for our newsletter. <a href="https://www.activecampaign.com/privacy-policy/">Read our privacy policy here.</a>

Link_html.png
Insert line
Example code used: 
<div style="height:10px;border-bottom:1px solid #CCCCCC">
&nbsp;
</div>

In this example, we used a separate HTML code block to create a line to insert between two form elements.

Insert_line_html.png

example_of_line.png

Create a bulleted list
Tags used <li> </li>

In this example, we wanted to list out what subscribers can expect to hear about when they sign up for our newsletter. This is how we set it up:

Learn more about the following: <li>Home energy check up</li><li>Solar consultation</li><li>Insulation</li>

bulleted_list_html.png

Add color to your text
Example code used:
<span style="color: #267ec2"; <p>Send us your name and email to sign up for our newsletter</p> </span>

In this example, we wanted to add color to the text in our HTML code block. The code used is found above.

apply_color_html.png

CSS

You can use the Custom CSS box and Inspector to modify visual elements of your form, such as adjusting the width of your submit button, adjusting font type and size, centering text in an element, changing the color of your text, and more. This option is located under the Style tab. All form types include the custom CSS box and Inspector.

custom_css_box.png

To use the Custom CSS box and inspector, click the “Style” tab located on the top right of your form editor. Then click the inspector button and target the element you wish to add custom styling to by clicking it.

Adjust the width of a form element

You can either use a percentage or pixel to determine the width of an element. In this example, we’re going to adjust the width of the “Submit” button:

  1. Go to “Style” then click “Inspector.”

    inspector_button.png

  2. Target the “Submit” button by clicking it.

    click_submit_button_to_adjust.png
  3. In the CSS box, enter:width: numberpx; And replace “number” with your own number. In this example, we used 250px:

    example_width.png

The submit button is now 250 pixel wide:
wide_submit_button.png

Adjust font type and size

You can use the CSS box to change the font for any element in your form. In this example, we’re going to modify the submit button by changing the font to Georgia and adjusting the font size to 25 pixel:

  1. Go to “Style” then click “Inspector.”

    inspector_button.png

  2. Target the element by clicking it. In this example, we’re choosing the “Submit” button. click_submit_button_to_adjust.png
  3. In the CSS box, enter:font-size: 25px;font-family: Georgia !important:

    css_for_font_type_and_size.png

The submit button’s font size and type is now adjusted:
new_submit_button.png

Center text using CSS

  1. Go to “Style” then click “Inspector.”

    inspector_button.png

  2. Target the element containing the text you wish to center by clicking it

    center_text_using_css.png
  3. In the CSS box, enter:text-align: center

    center_text_using_css_1.png

Your text is now centered:
text_centered.png

Add color with CSS

  1. Go to “Style” then click “Inspector.”

    inspector_button.png

  2. Target the element containing the text you wish to change the color for by clicking it.

    Click_element_to_add_color.png
  3. In the CSS box, type: color:#hexcodeforcolor; and replace “number” with your own number. In this example, we used #f441b8

    hex_color.png

Your text now has color applied to it:

blue_text.png

If you would like to learn more about CSS, there are several great resources out there such as this one.

Have more questions? Submit a request