diff --git a/CHANGES b/CHANGES index 95b7b5109bc..9c60620eb06 100644 --- a/CHANGES +++ b/CHANGES @@ -30,6 +30,7 @@ Bugs fixed different with one from ``index`` directive with "builtin" type * #7301: capital characters are not allowed for node_id * #7301: epub: duplicated node_ids are generated +* #6564: html: a width of table was ignored on HTML builder Testing -------- diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py index f94dd60a390..80cedd3bdd8 100644 --- a/sphinx/writers/html5.py +++ b/sphinx/writers/html5.py @@ -734,11 +734,14 @@ def visit_table(self, node: Element) -> None: self._table_row_index = 0 + atts = {} classes = [cls.strip(' \t\n') for cls in self.settings.table_style.split(',')] classes.insert(0, "docutils") # compat if 'align' in node: classes.append('align-%s' % node['align']) - tag = self.starttag(node, 'table', CLASS=' '.join(classes)) + if 'width' in node: + atts['style'] = 'width: %s' % node['width'] + tag = self.starttag(node, 'table', CLASS=' '.join(classes), **atts) self.body.append(tag) def visit_row(self, node: Element) -> None: