# Span

The **Span** class represents an inline object that allows you to display formatted text. A **Span** can only be used in the context of a **Paragraph**. As the spans are inline elements they get placed one after another and the text inside them gets wrapped to the next line if the space is insufficient.

This topic will explain you how to:

* [Use Spans](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/span#use-spans)

* [Add Text to a Span](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/span#add-text-to-a-span)

* [Customize a Span](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/span#customize-a-span)

## Use Spans

The **Spans** can be used only in the context of the [Paragraph](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/paragraph) element. The **Paragraph** exposes a collection of **Inlines**, to which the spans can be added.

```C#
Section section = new Section();
Paragraph paragraph = new Paragraph();
Span span = new Span("Span declared in code-behind");
paragraph.Inlines.Add(span);
section.Blocks.Add(paragraph);
this.radRichTextEditor1.Document.Sections.Add(section);

```

```VB.NET
Dim section As New Section()
Dim paragraph As New Paragraph()
Dim span As New Span("Span declared in code-behind")
paragraph.Inlines.Add(span)
section.Blocks.Add(paragraph)
Me.radRichTextEditor1.Document.Sections.Add(section)

```

## Add Text to a Span

To specify the text in the **Span** you can use its **Text** property.

```C#
Section section = new Section();
Paragraph paragraph = new Paragraph();
Span span = new Span("Span declared in code-behind");
paragraph.Inlines.Add(span);
section.Blocks.Add(paragraph);
this.radRichTextEditor1.Document.Sections.Add(section);

```

```VB.NET
Dim section As New Section()
Dim paragraph As New Paragraph()
Dim span As New Span("Span declared in code-behind")
paragraph.Inlines.Add(span)
section.Blocks.Add(paragraph)
Me.radRichTextEditor1.Document.Sections.Add(section)

```

> caution The **Text** property of a **Span** cannot be set to an empty string, as spans that do not contain any text are considered invalid. If you add an empty span in the document programmatically, an exception will be thrown.

## Customize a Span

The **Span** class exposes several properties that allow you to customize the layout of the elements placed underneath it. Here is a list of them:

* **BaselineAlignment** - indicates whether the text is **Baseline**, **Subscript** or **Superscript**.

* **FontFamily** - represents the name of the text's font.

* **FontSize** - represent the size of the text.

* **FontStyle** - indicates whether the text should have its style set to italic or to normal.

* **FontWeight** - represents the value for the text's weight.

* **ForeColor** - represents the foreground color for the text.

* **HighlightColor** - represents the background color for the text.

* **Strikethrough** - indicates whether the text should be stroke through.

* **UnderlineDecoration** - indicates whether the text should be underlined.

## See Also

* [Document Elements](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/overview)

* [Section](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/section)

* [Paragraph](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/paragraph)

* [RadDocument](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/raddocument)

* [Inline Image](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/inline-image)

* [Hyperlink](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/hyperlink)
