Bug 291407

Summary: position: relative on a <tr> doesn't create a containing block for absolutely positioned child elements or pseudo-elements, causing them to overflow outside the expected bounds.
Product: WebKit Reporter: Moubeen awan <moubin.shiraz>
Component: TablesAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: bfulgham, karlcow, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
We are using absolutely positioned pseudo-elements on the <tr> to render a vertical line and circle beside each row for visual hierarchy. This layout works correctly in most browsers (see Other Browse
none
testcase
none
rendering in safari, firefox, chrome none

Moubeen awan
Reported 2025-04-10 22:19:00 PDT
Created attachment 474896 [details] We are using absolutely positioned pseudo-elements on the <tr> to render a vertical line and circle beside each row for visual hierarchy. This layout works correctly in most browsers (see Other Browse WHAT: When applying position: relative to a <tr> element and using absolutely positioned pseudo-elements (e.g., ::before, ::after) inside it, Safari fails to contain those pseudo-elements within the row's boundaries. This causes layout inconsistencies in Safari compared to other browsers (Chrome, Firefox, Edge), where the pseudo-elements remain properly bounded within the table row. We use a vertical line and a circle for visual markers alongside each <tr> via ::before and ::after. These are positioned absolutely relative to the <tr>. In Safari, these pseudo-elements render incorrectly — they overflow outside the row, not aligning visually with their associated content. STEPS TO REPRODUCE: 1: Create a <table> with multiple <tr> elements. 2: Add position: relative to the <tr>. 3: Add ::before or ::after pseudo-elements with position: absolute and some content (e.g., a vertical line or shape). 4: Observe the rendering in Safari vs. other browsers. EXPECTED BEHAVIOR (OTHER BROWSERS): The absolutely positioned pseudo-elements are bounded by their parent <tr> and align visually as expected. ACTUAL BEHAVIOR (SAFARI): The pseudo-elements overflow or misalign because Safari doesn't treat <tr> as a positioning context when position: relative is applied. ENVIRONMENT: Safari Version: Version 18.3 (20620.2.4.11.5) macOS Version: 15.3.1 (Sequoia) Tested also on: Chrome, Firefox — works correctly
Attachments
We are using absolutely positioned pseudo-elements on the <tr> to render a vertical line and circle beside each row for visual hierarchy. This layout works correctly in most browsers (see Other Browse (599.17 KB, image/jpeg)
2025-04-10 22:19 PDT, Moubeen awan
no flags
testcase (931 bytes, text/html)
2025-05-06 23:13 PDT, Karl Dubost
no flags
rendering in safari, firefox, chrome (1.28 MB, image/png)
2025-05-06 23:15 PDT, Karl Dubost
no flags
Radar WebKit Bug Importer
Comment 1 2025-04-17 22:19:12 PDT
Karl Dubost
Comment 2 2025-05-06 23:01:03 PDT
Moubeen Awan, Thanks for the bug report. It would be easier to diagnose if you had a simple code example.
Karl Dubost
Comment 3 2025-05-06 23:13:51 PDT
Created attachment 475153 [details] testcase Ok I created another testcase for it which shows clearly how tr {position: relative} has a different behavior on different browsers.
Karl Dubost
Comment 4 2025-05-06 23:15:27 PDT
Created attachment 475154 [details] rendering in safari, firefox, chrome This shows the current rendering in different browsers.
Karl Dubost
Comment 5 2025-05-06 23:17:36 PDT
This is indeed a duplicate of Bug 240961 *** This bug has been marked as a duplicate of bug 240961 ***
Note You need to log in before you can comment on or make changes to this bug.