---
title: "encapsLines"
manual: "TypoScript Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3tsref:encapslines@main"
source: "Functions/Encapslines.rst"
rendered: "2026-09-19T06:55:14+00:00"
---

# encapsLines {#encapslines}

This function is a sub-function of [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main) and can be used
like this:

**EXT:my_extension/Configuration/Sets/Main/setup.typoscript**

```typoscript
page.20 = TEXT
page.20 {
  value (
        First line of text
        Some <div>text</div>
        <p>Some text</p>
        <div>Some text</div>
        <B>Some text</B>
    )
  stdWrap.encapsLines {
    encapsTagList = div, p
    remapTag.P=DIV
  }
}

```

-   [Properties](https://docs.typo3.org/permalink/t3tsref:properties@main)
-   [Examples](https://docs.typo3.org/permalink/t3tsref:examples@main)

## Properties {#encapslines-properties}

### encapsTagList {#encapslines-encapstaglist}

-   **encapsTagList**

    -   *Type:* list of [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main)

    List of tags which qualify as encapsulating tags. Must be lowercase.

    **Example**

    **EXT:site_package/Configuration/Sets/Main/setup.typoscript**

    ```typoscript
    encapsTagList = div, p
    ```

    This setting will recognize the highlighted lines below as encapsulated lines:

    **Example input**

    ```text
    First line of text
    Some <div>text</div>
    <p>Some text</p>
    <div>Some text</div>
    <B>Some text</B>
    ```

### remapTag.\[*tagname*\] {#encapslines-remaptag}

-   **remapTag**

    -   *Type:* array of [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main)

    Enter a new tag name here if you wish the tag name of any encapsulation
    to be unified to a single tag name.

    For instance, setting this value to `remapTag.P=DIV` would convert:

    ```html
    <p>Some text</p>
    <div>Some text</div>
    ```

    to :

    ```html
    <div>Some text</div>
    <div>Some text</div>
    ```

    (\[*tagname*\] is in uppercase.)

### addAttributes.\[*tagname*\] {#encapslines-addattributes}

-   **addAttributes**

    -   *Type:* array of [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main)
    -   *Default:* Always override/set the value of the attributes.

    Attributes to set in the encapsulation tag.

    (\[*tagname*\] is in uppercase.)

    **EXT:site_package/Configuration/Sets/Main/setup.typoscript**

    ```typoscript
    addAttributes.P.setOnly = exists
    ```

    -   **exists**

        This will set the value ONLY if the property does not already exist.

    -   **blank**

        This will set the value ONLY if the property does not already exist OR is
        blank ("").

    **Example**

    **EXT:site_package/Configuration/Sets/Main/setup.typoscript**

    ```typoscript
    addAttributes.P {
      style = padding-bottom: 0px; margin-top: 1px; margin-bottom: 1px;
      align = center
    }

    ```

### removeWrapping {#encapslines-removewrapping}

-   **removeWrapping**

    -   *Type:* [boolean](https://docs.typo3.org/permalink/t3tsref:data-type-boolean@main)

    If set, then all existing wrapping will be removed.

    This:

    **Example input**

    ```text
    First line of text
    Some <div>text</div>
    <p>Some text</p>
    <div>Some text</div>
    <b>Some text</b>
    ```

    becomes this:

    **Example output**

    ```text
    First line of text
    Some <div>text</div>
    Some text
    Some text
    <b>Some text</b>
    ```

### wrapNonWrappedLines {#encapslines-wrapnonwrappedlines}

-   **wrapNonWrappedLines**

    -   *Type:* [](https://docs.typo3.org/permalink/t3tsref:stdwrap-wrap@main)

    Wrapping for non-encapsulated lines

    **Example**

    **EXT:site_package/Configuration/Sets/Main/setup.typoscript**

    ```typoscript
    wrapNonWrappedLines = <p>|</p>
    ```

    This:

    ```html
    First line of text
    <p>Some text</p>
    ```

    becomes this:

    ```html
    <P>First line of text</P>
    <p>Some text</p>
    ```

### innerStdWrap_all {#encapslines-innerstdwrap-all}

-   **innerStdWrap_all**

    -   *Type:* [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)

    Wraps the content inside all lines, whether they are encapsulated or
    not.

### encapsLinesStdWrap.\[*tagname*\] {#encapslines-encapslinesstdwrap}

-   **encapsLinesStdWrap**

    -   *Type:* array of [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main) / [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)

    Wraps the content inside all encapsulated lines.

    (\[*tagname*\] is in uppercase.)

### defaultAlign {#encapslines-defaultalign}

-   **defaultAlign**

    -   *Type:* [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main) / [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)

    If set, this value is set as the default "align" value of the wrapping
    tags, both from [encapsTagList](https://docs.typo3.org/permalink/t3tsref:encapslines-encapstaglist@main) and
    [nonWrappedTag](https://docs.typo3.org/permalink/t3tsref:encapslines-nonwrappedtag@main)

### nonWrappedTag {#encapslines-nonwrappedtag}

-   **nonWrappedTag**

    -   *Type:* `tagname`

    For all non-wrapped lines, you can set a tag here in which they
    should be wrapped. Example would be "p". This is an alternative to
    `wrapNonWrappedLines` and has the advantage that its attributes are
    set by `addAttributes` as well as `defaultAlign`.
    Thus you can match the wrapping tags used for non-wrapped and wrapped
    lines more easily.

## Examples {#encapslines-examples}

### `<p>` tag is used to encapsulate each line {#encapslines-examples-tag-used-encapsulate}

**EXT:site_package/Configuration/Sets/Main/setup.typoscript**

```typoscript
encapsLines {
  encapsTagList = div,p
  remapTag.DIV = P
  wrapNonWrappedLines = <p>|</p>
  innerStdWrap_all.ifEmpty = &nbsp;
}

```

This example shows how to handle content rendered by TYPO3 and
stylesheets where the `<p>` tag is used to encapsulate each line.

Say, you have made this content with the rich text editor:

**Example input**

```none
This is line # 1

[Above is an empty line!]
<div style="text-align: right;">This line is right-aligned.</div>
```

After being processed by encapsLines with the above configuration, the
content looks like this:

**Example output**

```html
<p>This is line # 1 </p>
<p>&nbsp;</p>
<p>[Above is an empty line!] </p>
<p style="text-align: right;">This line is right-aligned.</p>
```

Each line is nicely wrapped with `<p>` tags. The line from the database
which was *already* wrapped (but in `<div>` tags) has been converted to
`<p>`, but keeps its alignment. Overall, notice that the rich text editor
ONLY stored the line which was in fact right-aligned - every other line from the
RTE was stored without any wrapping tags, so that the content in the database
remains as human readable as possible.

### Advanced example {#encapslines-examples-advanced-example}

**EXT:site_package/Configuration/Sets/Main/setup.typoscript**

```typoscript
# Make sure nonTypoTagStdWrap operates
# on content outside <typolist> and <typohead> only:
tt_content.text.20.parseFunc.tags.typolist.breakoutTypoTagContent = 1
tt_content.text.20.parseFunc.tags.typohead.breakoutTypoTagContent = 1
# ... and no <br> before typohead.
tt_content.text.20.parseFunc.tags.typohead.stdWrap.wrap >
# Setting up nonTypoTagStdWrap to wrap the text with p tags
tt_content.text.20.parseFunc.nonTypoTagStdWrap >
tt_content.text.20.parseFunc.nonTypoTagStdWrap.encapsLines {
  encapsTagList = div,p
  remapTag.DIV = P
  wrapNonWrappedLines = <p style="margin: 0 0 0;">|</p>

  # Forcing these attributes onto the encapsulation tags if any
  addAttributes.P {
    style=margin: 0 0 0;
  }
  innerStdWrap_all.ifEmpty = &nbsp;
}
# Finally removing the <br> tag after the content...
tt_content.text.20.wrap >

```

This is an example of how to wrap the table field `tt_content.bodytext`
with `<p>` tags, setting the line distances to regular space like that
generated by a `<br>` tag, but staying compatible with the RTE features
such as assigning classes and alignment to paragraphs.
