RESOLVED FIXED 138577
th { text-align: inherit; } is not respected
https://bugs.webkit.org/show_bug.cgi?id=138577
Summary th { text-align: inherit; } is not respected
Anthony Ryan
Reported 2014-11-10 13:56:28 PST
Example URL: http://codepen.io/anthonyryan1/pen/QwLZZZ The expected behavior when using text-align: inherit; on a th is to inherit the text alignment of a parent element, in the case of my example left. Rather than doing this Safari uses the useragent default for th which is text-align: center. Verified in Safari 8 and the latest WebKit Nightly build. Other browsers: Firefox 33: Working as expected Internet Explorer 11: Working as expected Chrome 39: Also broken.
Attachments
Anthony Ryan
Comment 1 2014-11-10 13:56:56 PST
Anthony Ryan
Comment 2 2016-04-18 01:17:00 PDT
Radar WebKit Bug Importer
Comment 3 2022-06-02 01:09:08 PDT
Karl Dubost
Comment 4 2022-06-02 01:14:16 PDT
This issue forced Bootstrap to use `-webkit-match-parent` on their CSS https://github.com/twbs/bootstrap/issues/30321#issuecomment-592981559 which in return makes it hard to remove it from the Web platform without breaking Safari. If it is being fixed it will help to obsolete it, and convince BootStrap to remove it too. The WPT has already a test to remove the support of `-webkit-match-parent` https://github.com/web-platform-tests/wpt/commit/006029222c021a7c0b524328b0d3385cf4a97c95
Karl Dubost
Comment 5 2022-06-02 02:20:30 PDT
Filed https://github.com/whatwg/html/issues/7978 because the spec says Safari does the right thing. but Firefox and Chrome do differently. ``` data:text/html,<!doctype%20html><table><tr><th%20style="text-align:inherit">START</th></tr><tr><td>AAAAAAAAAAAAAA</td></tr></table> ```
Tim Nguyen (:ntim)
Comment 6 2022-06-02 13:13:46 PDT
This is the relevant bit in WebKit: https://webkit-search.igalia.com/webkit/rev/26eff7cbe4e53bbd8b325ee12a3567128ba52d2e/Source/WebCore/style/StyleAdjuster.cpp#318-323 I personally haven't tested which approach works, but the 2 I have in mind are: 1. Add a applyInheritTextAlign function here: https://webkit-search.igalia.com/webkit/rev/26eff7cbe4e53bbd8b325ee12a3567128ba52d2e/Source/WebCore/style/StyleBuilderCustom.h#197-207 that sets both textAlign, but also hasExplicitlySetTextAlign(). This needs to change: https://webkit-search.igalia.com/webkit/rev/26eff7cbe4e53bbd8b325ee12a3567128ba52d2e/Source/WebCore/css/CSSProperties.json#4590 to "custom": "All" in order to work. 2. Remove the StyleAdjuster code, do like Firefox/Chrome and add an `-internal-center-or-inherit` value, implement it in https://webkit-search.igalia.com/webkit/rev/26eff7cbe4e53bbd8b325ee12a3567128ba52d2e/Source/WebCore/style/StyleBuilderConverter.h#609 , something like: ``` if (primitiveValue.valueID() == CSSValueInternalCenterOrInherit) if (parentStyle.textAlign() != TextAlign::Start) return parentStyle.textAlign(); return TextAlign::Center; ```
Ryan Reno
Comment 7 2022-06-14 09:38:07 PDT
Ryan Reno
Comment 8 2022-06-14 16:13:12 PDT
Last PR ended up breaking some WPT tests for `all: revert`. I'm going to go for Tim's #2 suggestion and use an internal CSS property instead.
Ryan Reno
Comment 9 2022-06-15 19:43:50 PDT
EWS
Comment 10 2022-06-16 19:47:52 PDT
Committed r295625 (251630@main): <https://commits.webkit.org/251630@main> Reviewed commits have been landed. Closing PR #1568 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.