Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- Fix `hex_to_rgb` parsing of 3-digit shorthand hexadecimal colors such as `#FFF` [[#5662](https://github.com/plotly/plotly.py/pull/5662)], with thanks to @genrichez for the contribution!
- Add `<!doctype html>` to the `to_html()` template to comply with modern web standards [[#5693](https://github.com/plotly/plotly.py/pull/5693)], with thanks to @mishrakushal for the contribution!


## [6.9.0] - 2026-07-09
Expand Down
6 changes: 5 additions & 1 deletion plotly/io/_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,12 @@ def to_html(

if full_html:
return """\
<!doctype html>
<html>
<head><meta charset="utf-8" /></head>
<head>
<meta charset="utf-8" />
<style>html, body {{height: 100%;}}</style>
</head>
<body>
{div}
</body>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core/test_offline/test_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_default_plot_generates_expected_html(self):
self.assertIn(plotly_config_script, html) # so is config
self.assertIn(PLOTLYJS, html) # and the source code
# and it's an <html> doc
self.assertTrue(html.startswith("<html>") and html.endswith("</html>"))
self.assertTrue(html.startswith("<!doctype html>") and html.endswith("</html>"))

def test_including_plotlyjs_truthy_html(self):
# For backwards compatibility all truthy values that aren't otherwise
Expand Down
4 changes: 2 additions & 2 deletions tests/test_io/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def test_plotly_mimetype_renderer_show(fig1, renderer):
# HTML
# ----
def assert_full_html(html):
assert html.startswith("<html")
assert html.startswith("<!doctype html")


def assert_not_full_html(html):
assert not html.startswith("<html")
assert not html.startswith("<!doctype html") and not html.startswith("<html")


def assert_html_renderer_connected(html):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_optional/test_offline/test_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ def test_default_mpl_plot_generates_expected_html(self):
self.assertTrue(data_json in html) # data is in there
self.assertTrue(PLOTLYJS in html) # and the source code
# and it's an <html> doc
self.assertTrue(html.startswith("<html>") and html.endswith("</html>"))
self.assertTrue(
html.startswith("<!doctype html>") and html.endswith("</html>")
)