Skip to content

Commit 606d959

Browse files
docs(readme): update FAQ with section on invalid HTML
1 parent d30bfdc commit 606d959

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ The first argument is an object with the same output as [htmlparser2](https://gi
110110

111111
```js
112112
parse('<br>', {
113-
replace: function(domNode) {
113+
replace: function (domNode) {
114114
console.dir(domNode, { depth: null });
115115
}
116116
});
@@ -250,6 +250,16 @@ Check if your arguments are valid. Also, see ["Does this library sanitize invali
250250

251251
Yes, this library supports server-side rendering on Node.js. See [demo](https://repl.it/@remarkablemark/html-react-parser-SSR).
252252

253+
#### Why are my elements nested incorrectly?
254+
255+
Make sure your [HTML markup is valid](https://validator.w3.org/). The HTML to DOM parsing will be affected if you're using self-closing syntax (`/>`) on non-void elements:
256+
257+
```js
258+
parse('<div /><div />'); // returns single element instead of array of elements
259+
```
260+
261+
See [#158](https://github.com/remarkablemark/html-react-parser/issues/158).
262+
253263
## Benchmarks
254264

255265
```sh

0 commit comments

Comments
 (0)