Apply a CSS class according to a CMS collection field

Hi there,

I would like an HTML embed element to become a div block (a specific class), according to a CMS collection filed.

For example, I created the “Special div 1” class, as you can see here:
Capture d’écran 2022-08-21 à 14.50.50

I also created a CMS collection field called “my special div” where I wrote “Special div 1”.
Capture d’écran 2022-08-21 à 14.56.22

Then, I created an HTML embed element this way:
Capture d’écran 2022-08-21 à 14.58.07

Of course, I would like it to become a “my special div” div, but it doesn’t work.

I would like to know what I’m doing wrong, please.

Thank you for your help!

You’re not missing anything, that’s expected.
The Custom Code Embed component is a div in itself, and what you type in will be inside of that div. Always. That’s how Webflow works and you’ll have to deal with this, and find a solution while dealing with this.

1 Like

@vincent Thank you, Vincent.

I understand your point.

To solve my problem, what should I do to apply a class (Special div 1, Special div 2, etc.) to a div block depending on the “My special div” CMS collection field?

Thank you for your answer.