Formatting text elements is important for making your site's text content visually appealing and consistent. You can edit text elements directly in the editor using the Edit Text button. However, sometimes you might want to change their formatting or content dynamically through code. This method is especially useful for adjusting text based on user interactions or when working with data-driven content.
For example, you might want to:
When you edit the content of a text element using the text
or html
property, it will affect its formatting.
Note: You can also format text elements using the text CSS classes.
text
propertyWhen you change a text element's content using it's text
property, it keeps the existing formatting.
The formatting in the text element will be uniform across all its content, meaning different parts of the text cannot have different formats. If you applied more than one format in the editor, the first style will be used for all the content set with the text property.
html
propertyWhen you change a text element's content using it's html
property, its formatting is set by the markup you apply.
You can format the content using supported HTML formatting.
When using heading or paragraph tags, the text inside the tags is formatted according to the site's themes.
Note: Themes are defined site-wide, so when you update the formatting of a theme, all relevant text formatting will update as well.