[style.css] css inheritance not working properly
While writing my config file I noticed a lot of inconsistencies and things not working and upon investigation it seems the css is not being interpreted correctly. Here a example that showcases the behavior in question:
*
{
background-color: #000000;
color: #ff0000;
}
#waybar
{
background-color: #ffffff;
}
#workspaces button
{
padding: 5px;
background-color: #888888;
color: #0000ff;
}
#bluetooth
{
color: #0000ff;
}
Using following css I get this result:
Notice how the waybar background should be white, but is for some reason being overridden by *. The same happens with the icons inside the workspace buttons since they should have blue color and gray background. But the background of the button itself is correct. The bluetooth module also takes on the correct color. From what I can tell, the issue seems to be that properties from parents aren't being inherited properly.
Here is what I would expect it to look like by removing the * rule:
I'm on Arch Linux via Hyprland using Waybar v0.14.0
This is expected GTK CSS behavior, not a Waybar bug — two things are going on:
1. background-color is not inherited; it's painted per-node. Your * rule sets a black background on every node, including the child boxes/widgets that sit in front of the window. #waybar does set the window background to white (an id selector beats *), but the black child nodes are drawn on top of it, so the white is never visible. You can see the node tree with waybar -l debug; it looks roughly like:
window#waybar.background
decoration
box.horizontal
box.horizontal.modules-left
widget
label#clock.module
box#workspaces.horizontal.module
button
label
* matches all of these and paints each one black.
2. The workspace icons: * sets color/background-color directly on the inner label node. An explicit rule always beats an inherited value, so the blue/gray you set on #workspaces button never reaches the label inside it.
The fix is simply not to use * for background-color/color (or to scope it tightly) and set colors on the specific nodes you care about — which is exactly why removing the * rule gives you the result you expected.
Closing — reopen if something still looks off. 🙏