Search...
html
Sets or gets the contents of a text element using standard HTML.
Description
Setting the html
property sets the text and styling of
the text element. You can use a subset of HTML tags and CSS attributes
as described above. Any text that the element
already contained is replaced.
Getting the html
property returns the element's text, including
HTML tags.
The html
property maps the Editor's built-in text themes and custom
formatting to HTML and CSS as described here.
To set or get the plain, unstyled contents of a text element, use the
text
property instead.
Type:
stringRead & Write
Related Content:
Was this helpful?
Get a text element's HTML content
Copy Code
1let value = $w("#textElement").html // "<b>Bold Text</b>"
Set a text element's HTML content
Copy Code
1$w("#textElement").html = "<b>Bold Text</b>";
Set a text element's HTML content using inline styling
This example uses multiple properties of the style attribute to set the text element's HTML content.
Copy Code
1$w('#textElement').html = '<h1 style="color:blue;text-decoration:underline">Site Title Text</h1>';23$w("#textElement2").html = '<span style="color: red; font-size: 10.5em">Red text</span>';45$w("#textElement3").html = '<p style="color: green; font-size: 16px">Green text</p>';