# Text formatting and semantics

## Tags

MessageML supports the following tags for formatting content within a message:

| Tag                                                                                  | Description                                                                                                                                                                                                                                                                                                                                     | Optional attributes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `<br/>`                                                                              | Insert a line break.                                                                                                                                                                                                                                                                                                                            | None.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <p><code>\<a href="url"></code><br><code>Link Text</code><br><code>\</a></code></p>  | Insert a hyperlink that will be displayed in the message.                                                                                                                                                                                                                                                                                       | <p>• <code>href</code>: the URL of the link<br>• <code>class</code>: <a href="../../../../dev-tools/ui-style-guide/colors">color options</a>.</p>                                                                                                                                                                                                                                                                                                                                                            |
| `<b>text</b>`                                                                        | <p>Bold formatting.<br><br><strong>Note</strong>: when receiving a message from an Agent that contains whitespace between the last character in a bolded section and the closing <code>\</b></code> tag, the bold section will be returned in Markdown (i.e. surrounded by double '\*' characters) instead of XHTML tags.</p>                   | • `class`: [color options](https://docs.developers.symphony.com/dev-tools/ui-style-guide/colors).                                                                                                                                                                                                                                                                                                                                                                                                            |
| `<i>text</i>`                                                                        | <p>Italics formatting.<br><br><strong>Note</strong>: when receiving a message from an Agent that contains whitespace between the last character in an italics-formatted section and the closing <code>\</i></code> tag, the italics section will be returned in Markdown (i.e. surrounded by single '\*' characters) instead of XHTML tags.</p> | • `class`: [color options](https://docs.developers.symphony.com/dev-tools/ui-style-guide/colors).                                                                                                                                                                                                                                                                                                                                                                                                            |
| <p><code>\<pre></code><br><code>preformatted text</code><br><code>\</pre></code></p> | Preformatted text.                                                                                                                                                                                                                                                                                                                              | <p>• <code>class</code>: <a href="../../../../dev-tools/ui-style-guide/colors">color options</a>.<br>• Non-HTML MessageML <a href="broken-reference">shorthand tags</a> are not supported inside <code>\<pre></code>.</p>                                                                                                                                                                                                                                                                                    |
| `<span>text</span>`                                                                  | <p>No formatting.<br>• This tag can be used to specify visual styles, by adding a <code>class</code> attribute.<br>• This tag is used to create <a href="../entities/structured-objects">Structured objects</a>.</p>                                                                                                                            | <p>• <code>class</code>: <a href="../../../../dev-tools/ui-style-guide/colors">color options</a>.<br>• <code>data-entity-id</code><br>• See below for list of translated PresentationML attributes.</p>                                                                                                                                                                                                                                                                                                      |
| `<code>code sample</code>`                                                           | Format the text as a block of code.                                                                                                                                                                                                                                                                                                             | <ul><li><code>language</code>: Use the language attribute to benefit from language specific code highlighting. The following languages are available: <code>c, cpp, csharp, css, html, java, js, jsx, php, python, r, typescript, tsx, plaintext, yaml, scala, json, shell, markdown</code></li><li>Note: <code>language</code> attribute is only available with Agent 20.14+.</li><li>Note: please see escaping rules for <a href="special-characters">Special Characters</a> when using code tag</li></ul> |

## Examples

Here after you can find an example of a message sent by a bot and containing these formatting and semantics tags as well as the structure of the messageML sent:

{% tabs %}
{% tab title="Message containing formatting and semantics tags" %}
![](https://3121587452-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB51RkjSmfA_ejydg4M-3415978100%2Fuploads%2Fh11lFzgmDfBIboXKEras%2Fmml_formatting.png?alt=media\&token=70d83ff2-9356-47f5-8ece-d7f4c200790e)
{% endtab %}

{% tab title="messageML structure" %}

```markup
<messageML>
    <h1>Formatting and semantics</h1>
    <p>This is a <a href="https://docs.developers.symphony.com/">Link</a> to our developer documentation.</p>
    <p>Part 1 of the paragraph separated from part 2 with a line break.<br/>Part 2 of the paragraph.</p>
    <p>This text can be either <b>bold</b> or <i>italic</i> or <span style="color:red;">red</span>, or even combine <b><i style="color:red;">several</i></b> formatting tags.</p>
    <pre>This is a preformatted text.</pre>
    <code language="html">&lt;h1&gt;Code sample&lt;/h1&gt;
&lt;p&gt;This is some html&lt;/p&gt;</code>
</messageML>
```

{% endtab %}
{% endtabs %}

## Versions and Compatibility

| Main features introduced                             | Agent needed to parse message sent by the bot | Client 2.0 release      | Backward client-compatibility behavior (e.g. external rooms) | Client 1.5 release      |
| ---------------------------------------------------- | --------------------------------------------- | ----------------------- | ------------------------------------------------------------ | ----------------------- |
| Initial release                                      | Since the first version                       | Since the first version | -                                                            | Since the first version |
| Closing \<b> and \<i> without line breaks\*          | Since the first version                       | Since the first version | -                                                            | 1.53                    |
| Support of the language attribute on \<code> blocks. | Agent 20.14                                   | Since the first version | -                                                            |                         |
