# RichText The **\** component parses and displays HTML text. > **NOTE** > > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. ## Child Components Not supported ## APIs RichText(content:string) **Parameters** | Name| Type| Mandatory | Description| | ------- | -------- | ------------- | -------- | | content | string | Yes | String in HTML format.| ## Events | Name| Description| | -------- | -------- | | onStart(callback: () => void) | Triggered when web page loading starts. | | onComplete(callback: () => void) | Triggered when web page loading is completed.| ## Supported Tags | Name| Description| Example| | -------- | -------- | -------- | | \

--\

| Defines six levels of headings in the HTML document. \

defines the most important heading, and \

defines the least important heading.| \

This is an H1 heading\

\

This is an H2 heading\

| | \

\

| Defines a paragraph.| \

This is a paragraph\

| | \
| Inserts a newline character.| \

This is a paragraph\
This is a new paragraph\

| | \ | Defines the font style for the text contained within it, including the font face, size, and color.| \This is in red\ | | \
| Defines a thematic break (such as a shift of topic) on an HTML page and creates a horizontal line.| \

This is a paragraph\

\
\

This is a paragraph\

| | \\ | Defines an image.| \\ | | \
\
| Defines a generic container that is generally used to group block-level elements. It allows you to apply CSS styles to multiple elements at the same time.| \
\

This is the heading in a div element\

\
| | \\ | Displays text in italic style.| \This is in italic style\| | \\ | Defines text that should be styled differently or have a non-textual annotation, such as misspelt words or a proper name in Chinese text. It is recommended that you avoid using the \ tag where it could be confused with a hyperlink.| \

\This is an underlined paragraph\\

| | \ | Used to embed CSS within an HTML document.| \ | | style | Defines the inline style of an element and is placed inside the tag. Use quotation marks (') to separate the styling text and use semicolons (;) to separate styles, for example, **style='width: 500px;height: 500px;border: 1px solid;margin: 0 auto;'**.| \

This is a heading\

\

This is a paragraph\

| | \ | Embeds or references a client-side script, such as JavaScript.| \ | ## Example You can preview how this component looks on a real device. The preview is not yet available in the DevEco Studio Previewer. ```ts // xxx.ets @Entry @Component struct RichTextExample { @State data: string = '

h1 heading

' + '

h1 italic

' + '

h1 underlined

' + '

h2 heading

' + '

h3 heading

' + '

Regular paragraph


' + '
' + '

Font size: 35px; line height: 45px

' + '

' + '

This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

'; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { RichText(this.data) .onStart(() => { console.info('RichText onStart'); }) .onComplete(() => { console.info('RichText onComplete'); }) } } } ``` ![richText](figures/richText.png) ## Precautions The underlying layer of the **\** component reuses the **\** component to provide basic capabilities, including but not limited to HTML page parsing and rendering. However, the **\** component is resources consuming. In scenarios where the **\** component is repeatedly used, for example, when it is repeatedly used in a list, frame freezing or slow response may occur.