Comment 34 for bug 324398

Revision history for this message
In , Congyi Wu (congyiwu) wrote :

I have a dark theme (http://www.kde-look.org/content/show.php/Tempered+Charcoal?content=67024) and I have black text on a dark background, even though the default text color should be white. I browsed through the khtml source and ended up finding a workaround that works for me:

KDE has base css files in /usr/share/apps/khtml/css/html4.css and
/usr/share/apps/khtml/css/quirks.css

Changing html4.css will change your default colors/layout, but web pages can still override your changes!

You can also copy html4 to your .kde directory instead of modifying it globally:

cd ~/.kde/share/apps/khtml/
mkdir css
cp /usr/share/apps/khtml/css/html4.css css

The section:
html {
        display: block;
        color: -khtml-text;
}
is responsible for the foreground text color. Somewhere in the khtml code, -khtml-text gets replaced by black. So if you want white text by default, just use color: white;

Further down in the css file are 2 more useful blocks:
@media print {
        body {
                display: block;
                margin: 0px;
        }
}

@media screen {
        body {
                display: block;
                margin: 10px;
        }
}

To get a white background change those blocks to:
@media print {
        body {
                display: block;
                margin: 0px;
                background-color: white;
        }
}

@media screen {
        body {
                display: block;
                margin: 10px;
                background-color: white;
        }
}

I kept my foreground text black and changed the background to white, and I haven't noticed any problems.