Repository: Textualize/textual

Issue:
`TabbedContent` styling affects child widgets
`TabbedContent` is a little too broad in how it styles some things; this can be shown with the following code:

```python
from textual.app import App, ComposeResult
from textual.containers import Horizontal, Vertical
from textual.widgets import Button, Tabs, TabbedContent, TabPane, Label

class TabsStyleLeakApp(App[None]):

    CSS = """
    Vertical, TabbedContent {
        width: 1fr;
    }
    """

    def stuff(self) -> ComposeResult:
        yield Label("This label is topmost")
        yield Button("This button is second")
        yield Tabs("After", "Button")

    def compose(self) -> ComposeResult:
        with Horizontal():
            with Vertical():
                yield from self.stuff()
            with TabbedContent():
                with TabPane("Test"):
                    yield from self.stuff()

if __name__ == "__main__":
    TabsStyleLeakApp().run()
```

This results in the following:

![Screenshot 2024-02-28 at 10 18 13](https://github.com/Textualize/textual/assets/28237/c35cc6a1-4973-48b8-a444-f92bc49dbc63)

Note how the `Tabs` is composed last but within the `TabbedContent` it's displaying first due to the use of `dock` on `Tabs` within `TabbedContent`.


Discussion:

Resolving patch:
diff --git a/src/textual/widgets/_tabbed_content.py b/src/textual/widgets/_tabbed_content.py
--- a/src/textual/widgets/_tabbed_content.py
+++ b/src/textual/widgets/_tabbed_content.py
@@ -229,12 +229,11 @@ class TabbedContent(Widget):
     """A container with associated tabs to toggle content visibility."""
 
     DEFAULT_CSS = """
-
     TabbedContent {
         height: auto;
-    }
-    TabbedContent Tabs {
-        dock: top;
+        &> ContentTabs {
+            dock: top;
+        }
     }
     """
 


Test patch:
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -35172,6 +35172,169 @@
   
   '''
 # ---
+# name: test_tabbed_content_styling_not_leaking
+  '''
+  <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
+      <!-- Generated with Rich https://www.textualize.io -->
+      <style>
+  
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Regular"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+          font-style: normal;
+          font-weight: 400;
+      }
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Bold"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+          font-style: bold;
+          font-weight: 700;
+      }
+  
+      .terminal-1634536353-matrix {
+          font-family: Fira Code, monospace;
+          font-size: 20px;
+          line-height: 24.4px;
+          font-variant-east-asian: full-width;
+      }
+  
+      .terminal-1634536353-title {
+          font-size: 18px;
+          font-weight: bold;
+          font-family: arial;
+      }
+  
+      .terminal-1634536353-r1 { fill: #c5c8c6 }
+  .terminal-1634536353-r2 { fill: #e1e1e1 }
+  .terminal-1634536353-r3 { fill: #e1e1e1;font-weight: bold }
+  .terminal-1634536353-r4 { fill: #474747 }
+  .terminal-1634536353-r5 { fill: #0178d4 }
+  .terminal-1634536353-r6 { fill: #454a50 }
+  .terminal-1634536353-r7 { fill: #e2e3e3;font-weight: bold }
+  .terminal-1634536353-r8 { fill: #000000 }
+  .terminal-1634536353-r9 { fill: #737373 }
+  .terminal-1634536353-r10 { fill: #323232 }
+      </style>
+  
+      <defs>
+      <clipPath id="terminal-1634536353-clip-terminal">
+        <rect x="0" y="0" width="975.0" height="584.5999999999999" />
+      </clipPath>
+      <clipPath id="terminal-1634536353-line-0">
+      <rect x="0" y="1.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-1">
+      <rect x="0" y="25.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-2">
+      <rect x="0" y="50.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-3">
+      <rect x="0" y="74.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-4">
+      <rect x="0" y="99.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-5">
+      <rect x="0" y="123.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-6">
+      <rect x="0" y="147.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-7">
+      <rect x="0" y="172.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-8">
+      <rect x="0" y="196.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-9">
+      <rect x="0" y="221.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-10">
+      <rect x="0" y="245.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-11">
+      <rect x="0" y="269.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-12">
+      <rect x="0" y="294.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-13">
+      <rect x="0" y="318.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-14">
+      <rect x="0" y="343.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-15">
+      <rect x="0" y="367.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-16">
+      <rect x="0" y="391.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-17">
+      <rect x="0" y="416.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-18">
+      <rect x="0" y="440.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-19">
+      <rect x="0" y="465.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-20">
+      <rect x="0" y="489.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-21">
+      <rect x="0" y="513.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1634536353-line-22">
+      <rect x="0" y="538.3" width="976" height="24.65"/>
+              </clipPath>
+      </defs>
+  
+      <rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-1634536353-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">TabbedContentStyleLeakTestApp</text>
+              <g transform="translate(26,22)">
+              <circle cx="0" cy="0" r="7" fill="#ff5f57"/>
+              <circle cx="22" cy="0" r="7" fill="#febc2e"/>
+              <circle cx="44" cy="0" r="7" fill="#28c840"/>
+              </g>
+          
+      <g transform="translate(9, 41)" clip-path="url(#terminal-1634536353-clip-terminal)">
+      <rect fill="#1e1e1e" x="0" y="1.5" width="146.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="146.4" y="1.5" width="829.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="25.9" width="109.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="134.2" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="146.4" y="25.9" width="829.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="12.2" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="50.3" width="109.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="134.2" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="146.4" y="50.3" width="829.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="99.1" width="341.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="366" y="99.1" width="585.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="99.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#24292f" x="24.4" y="123.5" width="390.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="414.8" y="123.5" width="536.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="123.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#24292f" x="24.4" y="147.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#24292f" x="36.6" y="147.9" width="366" height="24.65" shape-rendering="crispEdges"/><rect fill="#24292f" x="402.6" y="147.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="414.8" y="147.9" width="536.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="147.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#24292f" x="24.4" y="172.3" width="390.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="414.8" y="172.3" width="536.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="172.3" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="196.7" width="97.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="122" y="196.7" width="85.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="207.4" y="196.7" width="109.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="317.2" y="196.7" width="85.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="402.6" y="196.7" width="85.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="488" y="196.7" width="463.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="196.7" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="221.1" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="109.8" y="221.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="122" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="146.4" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="195.2" y="221.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="207.4" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="231.8" y="221.1" width="73.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="305" y="221.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="317.2" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="341.6" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="390.4" y="221.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="402.6" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="427" y="221.1" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="475.8" y="221.1" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="488" y="221.1" width="463.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="221.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="245.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="36.6" y="245.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="48.8" y="245.5" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="109.8" y="245.5" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="122" y="245.5" width="829.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="245.5" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="562.7" width="976" height="24.65" shape-rendering="crispEdges"/>
+      <g class="terminal-1634536353-matrix">
+      <text class="terminal-1634536353-r1" x="976" y="20" textLength="12.2" clip-path="url(#terminal-1634536353-line-0)">
+  </text><text class="terminal-1634536353-r3" x="24.4" y="44.4" textLength="109.8" clip-path="url(#terminal-1634536353-line-1)">Leak&#160;Test</text><text class="terminal-1634536353-r1" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-1634536353-line-1)">
+  </text><text class="terminal-1634536353-r4" x="0" y="68.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-2)">━</text><text class="terminal-1634536353-r4" x="12.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-2)">╸</text><text class="terminal-1634536353-r5" x="24.4" y="68.8" textLength="109.8" clip-path="url(#terminal-1634536353-line-2)">━━━━━━━━━</text><text class="terminal-1634536353-r4" x="134.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-2)">╺</text><text class="terminal-1634536353-r4" x="146.4" y="68.8" textLength="829.6" clip-path="url(#terminal-1634536353-line-2)">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</text><text class="terminal-1634536353-r1" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-2)">
+  </text><text class="terminal-1634536353-r1" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-1634536353-line-3)">
+  </text><text class="terminal-1634536353-r2" x="24.4" y="117.6" textLength="341.6" clip-path="url(#terminal-1634536353-line-4)">This&#160;label&#160;should&#160;come&#160;first</text><text class="terminal-1634536353-r1" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-1634536353-line-4)">
+  </text><text class="terminal-1634536353-r6" x="24.4" y="142" textLength="390.4" clip-path="url(#terminal-1634536353-line-5)">▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔</text><text class="terminal-1634536353-r1" x="976" y="142" textLength="12.2" clip-path="url(#terminal-1634536353-line-5)">
+  </text><text class="terminal-1634536353-r7" x="36.6" y="166.4" textLength="366" clip-path="url(#terminal-1634536353-line-6)">This&#160;button&#160;should&#160;come&#160;second</text><text class="terminal-1634536353-r1" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-1634536353-line-6)">
+  </text><text class="terminal-1634536353-r8" x="24.4" y="190.8" textLength="390.4" clip-path="url(#terminal-1634536353-line-7)">▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</text><text class="terminal-1634536353-r1" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-7)">
+  </text><text class="terminal-1634536353-r1" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-1634536353-line-8)">
+  </text><text class="terminal-1634536353-r3" x="48.8" y="239.6" textLength="61" clip-path="url(#terminal-1634536353-line-9)">These</text><text class="terminal-1634536353-r9" x="146.4" y="239.6" textLength="48.8" clip-path="url(#terminal-1634536353-line-9)">Tabs</text><text class="terminal-1634536353-r9" x="231.8" y="239.6" textLength="73.2" clip-path="url(#terminal-1634536353-line-9)">Should</text><text class="terminal-1634536353-r9" x="341.6" y="239.6" textLength="48.8" clip-path="url(#terminal-1634536353-line-9)">Come</text><text class="terminal-1634536353-r9" x="427" y="239.6" textLength="48.8" clip-path="url(#terminal-1634536353-line-9)">Last</text><text class="terminal-1634536353-r1" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-1634536353-line-9)">
+  </text><text class="terminal-1634536353-r10" x="24.4" y="264" textLength="12.2" clip-path="url(#terminal-1634536353-line-10)">━</text><text class="terminal-1634536353-r10" x="36.6" y="264" textLength="12.2" clip-path="url(#terminal-1634536353-line-10)">╸</text><text class="terminal-1634536353-r5" x="48.8" y="264" textLength="61" clip-path="url(#terminal-1634536353-line-10)">━━━━━</text><text class="terminal-1634536353-r10" x="109.8" y="264" textLength="12.2" clip-path="url(#terminal-1634536353-line-10)">╺</text><text class="terminal-1634536353-r10" x="122" y="264" textLength="829.6" clip-path="url(#terminal-1634536353-line-10)">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</text><text class="terminal-1634536353-r1" x="976" y="264" textLength="12.2" clip-path="url(#terminal-1634536353-line-10)">
+  </text><text class="terminal-1634536353-r1" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-1634536353-line-11)">
+  </text><text class="terminal-1634536353-r1" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-12)">
+  </text><text class="terminal-1634536353-r1" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-1634536353-line-13)">
+  </text><text class="terminal-1634536353-r1" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-1634536353-line-14)">
+  </text><text class="terminal-1634536353-r1" x="976" y="386" textLength="12.2" clip-path="url(#terminal-1634536353-line-15)">
+  </text><text class="terminal-1634536353-r1" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-1634536353-line-16)">
+  </text><text class="terminal-1634536353-r1" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-17)">
+  </text><text class="terminal-1634536353-r1" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-1634536353-line-18)">
+  </text><text class="terminal-1634536353-r1" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-1634536353-line-19)">
+  </text><text class="terminal-1634536353-r1" x="976" y="508" textLength="12.2" clip-path="url(#terminal-1634536353-line-20)">
+  </text><text class="terminal-1634536353-r1" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-1634536353-line-21)">
+  </text><text class="terminal-1634536353-r1" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-1634536353-line-22)">
+  </text>
+      </g>
+      </g>
+  </svg>
+  
+  '''
+# ---
 # name: test_tabbed_content_with_modified_tabs
   '''
   <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
diff --git a/tests/snapshot_tests/snapshot_apps/tabbed_content_style_leak_test.py b/tests/snapshot_tests/snapshot_apps/tabbed_content_style_leak_test.py
new file mode 100644
--- /dev/null
+++ b/tests/snapshot_tests/snapshot_apps/tabbed_content_style_leak_test.py
@@ -0,0 +1,14 @@
+from textual.app import App, ComposeResult
+from textual.widgets import Button, Label, TabbedContent, Tabs, TabPane
+
+class TabbedContentStyleLeakTestApp(App[None]):
+
+    def compose(self) -> ComposeResult:
+        with TabbedContent():
+            with TabPane("Leak Test"):
+                yield Label("This label should come first")
+                yield Button("This button should come second")
+                yield Tabs("These", "Tabs", "Should", "Come", "Last")
+
+if __name__ == "__main__":
+    TabbedContentStyleLeakTestApp().run()
diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py
--- a/tests/snapshot_tests/test_snapshots.py
+++ b/tests/snapshot_tests/test_snapshots.py
@@ -278,6 +278,10 @@ def test_tabbed_content_with_modified_tabs(snap_compare):
     assert snap_compare(SNAPSHOT_APPS_DIR / "modified_tabs.py")
 
 
+def test_tabbed_content_styling_not_leaking(snap_compare):
+    assert snap_compare(SNAPSHOT_APPS_DIR / "tabbed_content_style_leak_test.py")
+
+
 def test_option_list_strings(snap_compare):
     assert snap_compare(WIDGET_EXAMPLES_DIR / "option_list_strings.py")