diff --git a/changelog_unreleased/html/pr-7293.md b/changelog_unreleased/html/pr-7293.md
new file mode 100644
index 000000000..4cf00b2db
--- /dev/null
+++ b/changelog_unreleased/html/pr-7293.md
@@ -0,0 +1,24 @@
+#### Do not throw on broken html ([#7293](https://github.com/prettier/prettier/pull/7293) by [@fisker](https://github.com/fisker))
+
+
+```html
+
+
+<
+
+
+TypeError: Cannot read property 'start' of null
+ at hasTrailingLineBreak (https://prettier.io/lib/standalone.js:19694:169)
+ at forceBreakContent (https://prettier.io/lib/standalone.js:19668:154)
+ at Object.genericPrint$2 [as print] (https://prettier.io/lib/standalone.js:21068:126)
+ at callPluginPrintFunction (https://prettier.io/lib/standalone.js:15302:20)
+ at https://prettier.io/lib/standalone.js:15253:18
+ at Object.printComments (https://prettier.io/lib/standalone.js:14974:19)
+ at printGenerically (https://prettier.io/lib/standalone.js:15252:24)
+ at printChild (https://prettier.io/lib/standalone.js:21227:14)
+ at https://prettier.io/lib/standalone.js:21211:104
+ at FastPath.map (https://prettier.io/lib/standalone.js:15155:23)
+
+
+ <
+```
diff --git a/src/language-html/utils.js b/src/language-html/utils.js
index 6ba8e1ca3..705602b04 100644
--- a/src/language-html/utils.js
+++ b/src/language-html/utils.js
@@ -330,7 +330,8 @@ function hasTrailingLineBreak(node) {
(node.next
? node.next.sourceSpan.start.line > node.sourceSpan.end.line
: node.parent.type === "root" ||
- node.parent.endSourceSpan.start.line > node.sourceSpan.end.line)
+ (node.parent.endSourceSpan &&
+ node.parent.endSourceSpan.start.line > node.sourceSpan.end.line))
);
}
diff --git a/tests/html_basics/__snapshots__/jsfmt.spec.js.snap b/tests/html_basics/__snapshots__/jsfmt.spec.js.snap
index 4cbe261d9..2079732d9 100644
--- a/tests/html_basics/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/html_basics/__snapshots__/jsfmt.spec.js.snap
@@ -1,5 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`broken-html.html 1`] = `
+====================================options=====================================
+parsers: ["html"]
+printWidth: 80
+ | printWidth
+=====================================input======================================
+
+
+
+
+
+<
+
+=====================================output=====================================
+
+ <
+
+================================================================================
+`;
+
exports[`comment.html 1`] = `
====================================options=====================================
parsers: ["html"]
diff --git a/tests/html_basics/broken-html.html b/tests/html_basics/broken-html.html
new file mode 100644
index 000000000..d71fe1dbf
--- /dev/null
+++ b/tests/html_basics/broken-html.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+<