at (111,103) content-size 83.34375x198 table-row children: not-inline
+ BlockContainer at (112,193.265625) content-size 81.34375x17.46875 table-cell [BFC] children: inline
+ line 0 width: 81.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 10, rect: [112,193.265625 81.34375x17.46875]
+ "off-center"
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [0,0 800x312]
+ PaintableWithLines (BlockContainer) [8,100 784x204]
+ PaintableWithLines (TableWrapper(anonymous)) [108,100 89.34375x204]
+ PaintableBox (Box) [108,100 89.34375x204]
+ PaintableBox (Box) [109,101 83.34375x198] overflow: [109,101 85.34375x200]
+ PaintableBox (Box) [111,103 83.34375x198]
+ PaintableWithLines (BlockContainer) [111,103 83.34375x198]
+ TextPaintable (TextNode<#text>)
diff --git a/Tests/LibWeb/Layout/expected/table/table-align-center.txt b/Tests/LibWeb/Layout/expected/table/table-align-center.txt
new file mode 100644
index 0000000000..5bfc96d1f2
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/table/table-align-center.txt
@@ -0,0 +1,24 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+ BlockContainer at (0,0) content-size 800x220 [BFC] children: not-inline
+ BlockContainer at (8,8) content-size 784x204 children: not-inline
+ TableWrapper <(anonymous)> at (370.1875,8) content-size 59.625x204 [BFC] children: not-inline
+ Box at (371.1875,9) content-size 57.625x202 table-box [TFC] children: not-inline
+ Box at (371.1875,9) content-size 53.625x198 table-row-group children: not-inline
+ Box at (373.1875,11) content-size 53.625x198 table-row children: not-inline
+ BlockContainer at (374.1875,101.265625) content-size 51.625x17.46875 table-cell [BFC] children: inline
+ line 0 width: 51.625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 6, rect: [374.1875,101.265625 51.625x17.46875]
+ "center"
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+
+ViewportPaintable (Viewport<#document>) [0,0 800x600]
+ PaintableWithLines (BlockContainer) [0,0 800x220]
+ PaintableWithLines (BlockContainer) [8,8 784x204]
+ PaintableWithLines (TableWrapper(anonymous)) [370.1875,8 59.625x204]
+ PaintableBox (Box) [370.1875,8 59.625x204]
+ PaintableBox (Box) [371.1875,9 53.625x198] overflow: [371.1875,9 55.625x200]
+ PaintableBox (Box) [373.1875,11 53.625x198]
+ PaintableWithLines (BlockContainer) [373.1875,11 53.625x198]
+ TextPaintable (TextNode<#text>)
diff --git a/Tests/LibWeb/Layout/input/table/table-align-center-with-margin.html b/Tests/LibWeb/Layout/input/table/table-align-center-with-margin.html
new file mode 100644
index 0000000000..80fa8acde7
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/table/table-align-center-with-margin.html
@@ -0,0 +1,7 @@
+off-center |
diff --git a/Tests/LibWeb/Layout/input/table/table-align-center.html b/Tests/LibWeb/Layout/input/table/table-align-center.html
new file mode 100644
index 0000000000..59b23a5f0c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/table/table-align-center.html
@@ -0,0 +1,6 @@
+center |
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
index 0be2befb8b..70a4a5899a 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp
@@ -61,6 +61,15 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
return;
}
+ if (name == HTML::AttributeNames::align) {
+ if (value.equals_ignoring_ascii_case("center"sv)) {
+ style.set_property(CSS::PropertyID::MarginLeft, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
+ style.set_property(CSS::PropertyID::MarginRight, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
+ } else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::Float)) {
+ style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull());
+ }
+ return;
+ }
if (name == HTML::AttributeNames::bgcolor) {
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value);
| | | |