How can I wrap numbers and % symbols in a CMS field into a span using Webflow?

Published on
September 22, 2023

To wrap numbers and % symbols in a CMS field into a <span> using Webflow, you can use the following steps:

  1. Create a CMS collection: Start by creating a CMS collection in Webflow if you haven't already. This collection will store the content that you want to display, including the numbers and % symbols.

  2. Add a new text field: In the CMS collection editor, add a new text field for the numbers and % symbols. Give it a name that you can easily identify.

  3. Design your collection template: Go to the collection template page and design the layout as per your requirements. Add the text element where you want to display the CMS field.

  4. Open the text element settings: Select the text element that will display the CMS field, and open its settings panel.

  5. Click on the "+" icon in the text settings panel: In the settings panel, you will see an option to wrap specific characters or words with HTML tags. Click on the "+" icon next to this option to add a new rule.

  6. Specify the characters to wrap: In the rule settings, enter the characters that you want to wrap in a <span>. In this case, enter the numbers and % symbol that should be wrapped. For example, if you want to wrap all numbers and the % symbol, you can enter [0-9%] in the rule.

  7. Specify the HTML tag to use: Once you have specified the characters to wrap, select the HTML tag that you want to use. In this case, choose <span> from the drop-down list.

  8. Style the wrapped content: Finally, you can style the wrapped content using CSS. You can either add custom styles in the Webflow designer or use the built-in style options in the text settings panel.

By following these steps, you will be able to wrap numbers and % symbols in a CMS field into a <span> using Webflow.

Example
Suppose you have a CMS collection called "Numbers" with a text field called "Percentage". In the collection template page, you have a text element that displays the "Percentage" field content. You want to wrap the numbers and % symbol in the "Percentage" field with a <span>.

  1. Open the settings of the text element.
  2. Click on the "+" icon next to "Wrap with HTML tags" option.
  3. Enter [0-9%] in the rule settings.
  4. Select <span> from the drop-down list.
  5. Customize the styles of the wrapped content using CSS.

Now, the numbers and % symbol in the "Percentage" field will be wrapped in a <span>.

Additional Questions:

  1. How to add a text field in a Webflow CMS Collection?
  2. How to style CMS content in Webflow?
  3. Can I use custom code in Webflow to modify CMS content?