How to apply a Class or ID to a form field?

New Contributor

Hi

 

I want to apply a unique class or id to each individual field on my form. Can anyone suggest how to do this?

 

Thanks!

Reply
0 Upvotes
1 Reply 1
Highlighted
Advisor | Partner

Hi @thomaswil 

 

You can wrap the entire form in a module and apply a class to that wrapper like image below.

screenshot-community.hubspot.com-2020.06.16-00_47_28.png

 

Then when targeting individual fields, in css and js, you can target them by using type and field selectors.

 

.form_class input[type="text"],
.form_class input[type="name"],
.form_class input[type="tel"]

etc. and

.form_class input[type="text"]:first-of-type

etc.

Let me know if any questions!

 

Thanks!

Ajit