1

Does anyone know of a way to make the default SharePoint 2013 HTML editor output a P tag when you hit enter, as opposed to a Div?

0

2 Answers 2

1

According to the accepted answer given here (+ comments) it is not possible. The only work-around is as described by the answerer.

On the first line after typing but before hitting enter, select the text and on the ribbon goto Markup Styles > Paragraph. After that is will create a new paragraph for each line break.

1
  • 2
    Correct, you can't change the default behavior of the control. Outside of this answer you could custom code your own control, or use something like HTMLBox or other JavaScript Rich Text Editor. Dec 10, 2014 at 2:16
1

It depends where you use the HTML Editor on Publishing or Wiki Pages the default behaviour is that SharePoint always use a P in the content but never a div element. At least you haven't told him via RTE Style to use a div.

On lists: Multi Line Text field: If you have a multi line of text field it simply doesn't have paragraphs because it just renders text. To keep the content together SharePoint wraps it inside a div. Paragraph would't be the appropriate html element because there are no paragraph stored there. It is just text. You cannot format the output therefore it doesn't make sense to have a paragraph because every new line of text needs then to be force to create a new paragraph inside a paragraph. This is not support by HTML therefor Div is a better HTML Element.

Sample HTML output:

<div>This is my text including a new line
to show how the output will look like.

Here is just a another new line of content.
</div>

Rich Text Field: This field stores that data in the same way as a multi line of text field. The text will also be wrapped inside a div element. If you create content in the text field and do some line breaks you will also get a new paragraph with each new line. Like in word you can also do soft break by pressing shift+return.

Sample HTML Output:

<div><p>This is my text including a new line
to show how the output will look like.</p>
<p>Here is just a another new line of content.</p>
</div>

What would happen if SharePoint renders a P instead of a DIV Element would look like this:

<p>
    <p>This is my text including a new line
    to show how the output will look like.</p>
    <p>Here is just a another new line of content.</p>
</p>

Nesting paragraphs is not supported by HTML and will never be supported because it doesn't make sense. From logical and from a semantical point of view.

It would be interesting where you see the DIV instead of the P element. Then I can improve my answer.

5
  • The standard (publishing) page editor. Dec 10, 2014 at 15:01
  • Then this works with Paragraphs depending of which style you have selected. Do you have any guidance how to reproduce your behaviour? Dec 10, 2014 at 15:04
  • Open a new page. Type something. Hit enter. Dec 10, 2014 at 15:21
  • Yes and after saving I will see the content in clean paragraphs. Do you have some kind of customization in the rte? Dec 10, 2014 at 18:39
  • NO.Basic editor. Saves as Div. Dec 11, 2014 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.