# \[AS3\] Styling htmlText in TextArea

**URL:** <https://forum.kirupa.com/t/as3-styling-htmltext-in-textarea/221586>\
**Category:** flash\
**Created:** [April 5, 2007, 1:20pm UTC](https://forum.kirupa.com/t/as3-styling-htmltext-in-textarea/221586 "2007-04-05T13:20:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete\_zahut](https://avatars.discourse-cdn.com/v4/letter/p/91b2a8/32.png) [@pete\_zahut](https://forum.kirupa.com/u/pete_zahut)\
**Post date:** [April 5, 2007, 1:20pm UTC](https://forum.kirupa.com/t/as3-styling-htmltext-in-textarea/221586/1 "2007-04-05T13:20:45Z")

</div>

Hi,

How can I style my html content of a TextArea? I tried it like this but it keeps throwing errors:

var h1:Object = new Object();  
h1.fontFamily = “DistrictThin”;  
h1.color = “#FFCC00”;  
h1.fontSize = 30;  
h1.leading = 15;  
h1.display = “block”;

var css:StyleSheet = new StyleSheet();  
css.setStyle(“h1”,h1);

var styledTxt:TextArea = new TextArea();  
styledTxt.width = textBox.width;  
styledTxt.height = textBox.height;  
textBox.addChild(styledTxt);

styledTxt.styleSheet = css;  
styledTxt.htmlText = ‘\<h1\>Lorem Ipsum\</h1\>\<p\>dolor sit amet dolor sit amet dolor sit amet\</p\>’;

* * *

## Error: Error #2009: This method cannot be used on a text field with a style sheet. at flash.text::TextField/set defaultTextFormat() at mx.core::UITextField/set htmlText()[C:\dev\GMC\sdk\frameworks\mx\core\UITextField.as:314] at mx.controls::TextArea/mx.controls:TextArea::commitProperties()[C:\dev\GMC\sdk\frameworks\mx\controls\TextArea.as:1787] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:658] at Function/[http://adobe.com/AS3/2006/builtin::apply()](http://adobe.com/AS3/2006/builtin::apply()) at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7789] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7732] at flash.utils::Timer/flash.utils:Timer::\_timerDispatch() at flash.utils::Timer/flash.utils:Timer::tick()

Thanks! :block: :cross-eye
