diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
index a9407ec7a15..907a1ae018d 100644
--- a/sphinx/builders/html/__init__.py
+++ b/sphinx/builders/html/__init__.py
@@ -1044,7 +1044,7 @@ def hasdoc(name: str) -> bool:
# Note: warning will be removed at Sphinx-5.0 # RemovedInSphinx50Warning
try:
- ctx['css_files'].sort(key=lambda js: js.priority)
+ ctx['css_files'].sort(key=lambda css: css.priority)
except AttributeError:
logger.warning(__('Failed to sort css_files. Please use html_css_files '
'configuration to set up CSS files.'),