Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested paragraph tags not rendering on server #14409

Closed
Ehesp opened this issue Jun 21, 2020 · 10 comments
Closed

Nested paragraph tags not rendering on server #14409

Ehesp opened this issue Jun 21, 2020 · 10 comments
Labels
good first issue Easy to fix issues, good for newcomers Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@Ehesp
Copy link
Contributor

Ehesp commented Jun 21, 2020

Bug report

Describe the bug

I came across this "bug" when building out a website using a headless CMS. I injected my CMS content into my application via <p dangerouslySetInnerHTML={{ __html: externalHtml }} />, however the HTML output from the CMS also contains a nested <p> tag.

When I load the page from the server, the content does not show, when I navigate to a page via client routing, it shows.

To Reproduce

https://github.com/Ehesp/nextjs-html-rendering-issue

https://nextjs-html-rendering-issue.ehesp.vercel.app/

  1. Load the page (no text shows)
  2. Click the link to page 2, and then the link back to the root page
  3. The nested text now shows

Expected behavior

Technically nested p tags are incorrect and I sorted this by adding the HTML to an article tag, however since the output is different on server vs client it seems to be a bug?

Screenshots

Server:
image

Client:
image

System information

  • OS: macOS
  • Browser: chrome
  • Version of Next.js: v9.4.4
  • Version of Node.js: v12.9.1
@timneutkens timneutkens added the good first issue Easy to fix issues, good for newcomers label Jun 21, 2020
@fabrizzioalco
Copy link

I want to take a look at this

@Timer Timer added the Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). label Jun 24, 2020
@patrick-mcdougle
Copy link

patrick-mcdougle commented Jun 28, 2020

Nested <p> isn't allowed in the HTML specification, so I'd argue this is won't fix. <p> elements can only contain phrasing content (which <p> itself is not).

@fabrizzioalco
Copy link

fabrizzioalco commented Jun 28, 2020

@patrick-mcdougle HTML only have certain elements that can be nested.

is not one of those. Heres some information. https://stackoverflow.com/questions/9852312/list-of-html5-elements-that-can-be-nested-inside-p-element

@fabrizzioalco
Copy link

@patrick-mcdougle Thanks for the response and the help

@timneutkens
Copy link
Member

Nested <p> isn't allowed in the HTML specification, so I'd argue this is won't fix. <p> elements can only contain phrasing content (which <p> itself is not).

This is correct, I think the issue can be closed.

@Ehesp
Copy link
Contributor Author

Ehesp commented Jun 29, 2020

Yeah I understand it's not correct HTML, however wouldn't it make more sense for the output to be consistent (not render anything)?

@timneutkens
Copy link
Member

timneutkens commented Jun 29, 2020

<p><p>Hello World!!!</p></p> It seems that it does output, just the browser does not display it, you can check here: view-source:https://nextjs-html-rendering-issue.ehesp.vercel.app/

@Timer
Copy link
Member

Timer commented Jun 29, 2020

This seems to be a no-fix from the Next.js side. Can you please file this upstream with the React team? This seems to be a difference between ReactDOM client and server.

@Timer Timer closed this as completed Jun 29, 2020
@mattdell
Copy link

Also ran into this. Very peculiar behavior. It should just render the output, even if it isn't valid markup.

Or at least provide a warning.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

No branches or pull requests

7 participants