Streaming live at 10am (PST)

Apply webflow classes to embedded form

Overall, this question is about applying some webflow classes to an embedded form in webflow. Currently I just wanted to test if I could get elements inside my form by tag name. I started with a simple test, just getting all my h2 tags in my form. I also added an h2 into webflow for comparison.

The following code works as expected (the h2 tags all say “cat”) for the h2 inside webflow, but has no effect on the h2’s inside my embedded form. When I open the console and expand my element list the h2’s in my form appear, but the debugger includes a message that says “value below was evaluated just now.” This makes me think that my code can’t see the h2’s in my form because they haven’t been built yet, but I put this code just before the body tag and also inside a webflow ready wrapper. Any ideas on what to do?

Read only link:

var Webflow = Webflow || ;
Webflow.push(function () {
var h2Els = document.getElementsByTagName(‘h2’);
for (var i = 0; i < h2Els.length; i++) {
h2Els[i].innerText = “cat”;

Hi @Jeremy_D I think that’s possible. But just to be sure, can you please post your read-only link?

Its hard to answer. Anyway first try your code on codepen.

This code works fine.

var elem = $('#embedForm h2');

$.each(elem, function () {
		$(this).text( "Some new text." );


<form id="embedForm">
First name: <input type="text" name="FirstName" value="Mickey"><br>
Last name: <input type="text" name="LastName" value="Mouse"><br>
  <input type="submit" value="Submit">

Publish --> Result:

If you talk about form element - again should work fine (Same idea/trick).


Please test if your Heading is H2.

After doing some research I don’t think this is possible. I think because it violates the same origin policy ( Anyway, I think that I can’t access anything in my embedded form via javascript because it comes form Cognito forms rather than webflow.

If I’m wrong I’d be more than happy to be corrected as my route around this would be to hardcode the css tags and therefore lose all the power of webflow style classes.

Have you checked this?

Thanks! I was actually just looking at that documentation. I tried passing in my own style sheet but it wouldn’t let me because it was cross platform. Currently I’m trying to pass in the webflow url stylesheet, but I’ll need accessibility to style it with tags to access all the elements in the form. But I don’t think I can edit the webflow style sheet directly. Any other ideas?

What you can do is, once you’ve found the classes of the fields and labels, etc of your form:

  1. Drag a form element into the WF canvas
  2. Give those classes to the input fields to the ones in the form you just added
  3. Once finished remove the form from the canvas
  4. Export your style sheet file
  5. Pass it to the Cognito forms as mentioned in the document
1 Like

But doesn’t the file have to be hosted by webflow?

Well you need to link your form from cognito to the Webflow stylesheet.