diff --git a/Lib/http/server.py b/Lib/http/server.py
index 194a503c45f..a6100d48297 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -109,11 +109,10 @@ from http import HTTPStatus
# Default error message template
DEFAULT_ERROR_MESSAGE = """\
-
-
+
+
-
+
Error response
@@ -777,14 +776,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
displaypath = urllib.parse.unquote(path)
displaypath = html.escape(displaypath, quote=False)
enc = sys.getfilesystemencoding()
- title = 'Directory listing for %s' % displaypath
- r.append('')
- r.append('\n')
- r.append('' % enc)
- r.append('%s\n' % title)
- r.append('\n%s
' % title)
+ title = f'Directory listing for {displaypath}'
+ r.append('')
+ r.append('')
+ r.append('')
+ r.append(f'')
+ r.append(f'{title}\n')
+ r.append(f'\n{title}
')
r.append('
\n')
for name in list:
fullname = os.path.join(path, name)
diff --git a/Misc/NEWS.d/next/Library/2022-02-24-01-49-38.bpo-46736.NJcoWO.rst b/Misc/NEWS.d/next/Library/2022-02-24-01-49-38.bpo-46736.NJcoWO.rst
new file mode 100644
index 00000000000..fca7780b82e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-02-24-01-49-38.bpo-46736.NJcoWO.rst
@@ -0,0 +1,2 @@
+:class:`~http.server.SimpleHTTPRequestHandler` now uses HTML5 grammar. Patch
+by Dong-hee Na.