Disable auto-adding p tag around text in Rich Text source edit mode | Community
Skip to main content
Level 1
March 3, 2026
Solved

Disable auto-adding p tag around text in Rich Text source edit mode

  • March 3, 2026
  • 3 replies
  • 82 views

Hi Team,

I'm currently working on a custom component in AEM as a Cloud Service.

In the Rich Text Editor (RTE) field of my dialog, when switching to source edit mode (HTML view), I noticed that plain text input is automatically wrapped with <p> tags.

 

For example:

Input:

Hello World

Output:

<p>Hello World</p>

 

I would like to disable this behavior so that plain text remains unchanged, without being wrapped in <p> tags.

 

Is there any configuration available to prevent automatic <p> insertion in source mode?

Or would this require a custom plugin or overlay?

 

Thanks in advance for your help!

Best answer by VeenaVikraman

Hi ​@EddieHuang 
 

That's the OOTB behavior of AEM's Rich Text Editor. The RTE is designed to produce semantic HTML content, which is why it automatically wraps plain text in block-level elements like <p> tags—this ensures proper rendering. If you need to store plain text without HTML markup, use a Text Area field instead of RTE in your dialog definition. This is the standard approach for plain text input.

 

Thanks

Veena

3 replies

VeenaVikraman
Community Advisor
VeenaVikramanCommunity AdvisorAccepted solution
Community Advisor
March 3, 2026

Hi ​@EddieHuang 
 

That's the OOTB behavior of AEM's Rich Text Editor. The RTE is designed to produce semantic HTML content, which is why it automatically wraps plain text in block-level elements like <p> tags—this ensures proper rendering. If you need to store plain text without HTML markup, use a Text Area field instead of RTE in your dialog definition. This is the standard approach for plain text input.

 

Thanks

Veena

Level 1
March 3, 2026

Hi ​@EddieHuang ,

As ​@VeenaVikraman, this is the out-of-the-box (OOTB) behavior of the RTE. If you want to exclude these tags from your HTML, you’ll need to adjust the context in which you’re accessing the authored value.
<p> {properties.rteName  @ context='html'} </p>

Thanks,
Sai.

AmitVishwakarma
Community Advisor
Community Advisor
March 3, 2026

Hi ​@EddieHuang 
You cannot disable the auto <p> wrapping in AEM’s RTE. The RTE always normalizes content to valid block-level HTML when you leave source mode, which is explicitly documented: AEM “ensur[es] that the text is correctly contained/nested in blocks,” potentially changing your raw HTML edits when exiting source view.
See Source Editing Mode in https://experienceleague.adobe.com/en/docs/experience-manager-65/content/sites/classic-ui/authoring/classic-page-author-rich-text-editor#source-editing-mode

If you need plain text with no HTML tags, the supported options are:

  • Use a Granite textarea (plain text field) instead of an RTE in the dialog.
  • Or store in RTE and strip tags on read in your Sling Model/Servlet before rendering.

No official RTE config/plug‑in in AEM as a Cloud Service will keep raw plain text unwrapped in source mode; any overlay to fight this would be brittle and unsupported.

Amit Vishwakarma - Adobe Commerce Champion 2025 | 16x Adobe certified | 4x Adobe SME
partyush
Community Advisor
Community Advisor
March 3, 2026

Hi ​@EddieHuang 

Use the removeSingleParagraphContainer property in your RTE's htmlRules configuration to remove the wrapping <p> tag when only one paragraph exists. For true plain text without any HTML, consider using a simple TextArea field instead of RTE.

Here is how you can structure this in your component's dialog .content.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"

    jcr:primaryType="cq:Widget"

    fieldLabel="Text"

    name="./text"

    xtype="richtext">

    <htmlRules jcr:primaryType="nt:unstructured">

        <blockHandling

            jcr:primaryType="nt:unstructured"

            removeSingleParagraphContainer="{Boolean}true"/>

    </htmlRules>

</jcr:root>

 

and then  : <div>${properties.text @ context='html'}</div>

Try this and let me know in case of any issue 

Thanks 

PK