Bug 47320

Summary: [testcase] text and background uses colors from KDE color scheme if not specified in the html style
Product: [Applications] konqueror Reporter: Charles Samuels <charles>
Component: khtml rendererAssignee: Konqueror Developers <konq-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: ahd9ryi02, aiacovitti, ana, arne_bab, bluedzins, branan, chusty, congyiwu, daniel.hill, danielbarrettbolton, dsolaz, eli, finex, giecrilj, hackeron, i.zaufi, jamie, jlp, kde, kubry, larsivar, martin.hohenberg, meyerm, miklcct, missive, news, pete, peyotll, rfernandes, samuel.brack, scottsimus, trouble, zingeepe
Priority: VHI    
Version: 4.4.5   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: trying to fix
Patch to use theme's text color unless page's css selects otherwise
Improper default colour in Konqueror

Description Charles Samuels 2002-09-02 02:54:54 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           khtml
Version:           KDE 3.0.7 CVS/CVSup/Snapshot
Severity:          normal
Installed from:    Compiled sources
Compiler:          Not Specified
OS:                Linux
OS/Compiler notes: Not Specified

When you have the CDE color scheme or any KDE color scheme in which the foreground text color is White (or light) many pages are rendered with text white (And background white).

Easy way to reproduce:
- Set your color scheme to CDE.
- Start a new konqueror (starting a new one is important!)
- Go to one of the example sites below

Solutions:
- Enforce text color black
- Have an independent configuration for khtml colors

Examples:
http://developer.kde.org/
http://razor.sourceforge.net/


(Submitted via bugs.kde.org)
Comment 1 Kai Lahmann 2003-06-14 03:35:06 UTC
I remember to see a bug for the different problem (color: always black)....:) 
Comment 2 Roger Larsson 2003-08-06 22:53:40 UTC
* CDE color scheme. 
* kill all konqueror (including the preloaded) 
* visit both web pages - black text on white where expected. 
The bug was quite old... is this still a problem in 3.1.x? 
Comment 3 Charles Samuels 2003-08-06 23:52:21 UTC
 
Those URLs have been fixed, try this one: 
http://www.gothmetal.net/ 
 
 
Comment 4 Charles Samuels 2003-08-06 23:52:46 UTC
(wasn't logged in just now :) 
Comment 5 Roger Larsson 2003-08-07 00:15:15 UTC
I see no white background on that site :-) 
Can't reproduce it there with CDE colors - did you use other? 
 
But I found another one: 
  http://www.aftonbladet.se/ 
With CDE colors; background white, links yellow == unreadable 
 
If I configure the same color preference in mozilla only links in 
ads are yellow - links in body are OK. 
Comment 6 Stephan Kulow 2004-11-12 15:30:48 UTC
*** Bug 81057 has been marked as a duplicate of this bug. ***
Comment 7 Hackeron 2004-11-12 15:50:41 UTC
I have a black on black problem when I set foreground to white and background to black:

ftp://81.86.159.146/mutt.jpg

Very critical problem for me -- has been around for years.
Comment 8 Stephan Kulow 2004-11-12 16:00:08 UTC
usual fix: user defined stylesheet, overwriting default background
  body { background-color: white; }
   
Comment 9 Hackeron 2004-11-12 16:30:57 UTC
Thats not a fix. That gets rid of background images on the websites, and makes many websites unviewable as well.

If a webpage sets the font to white and background to black or a dark image, and you override the background. You are left with white on white.

What I did is override the font colour to dark grey. So atleast if a webpage opens with black background, I can see the text in grey. -- But that has its own disadvantages.
Comment 10 Stephan Kulow 2004-11-12 16:50:51 UTC
why should background-color: get rid of background images? That's either a lie or a bug.

And yes, you need to include color: in your overwrite too.
Comment 11 Hackeron 2004-11-12 17:35:30 UTC
I cant remember the specifics, my laptop is being repaired atm and I'm using firefox on this temporary machine. But I think it wasnt body { background-color } but *{ background-color } -- I remember body { } wasnt enough for some sites.
Comment 12 Stephan Kulow 2004-11-22 16:09:46 UTC
*** Bug 76686 has been marked as a duplicate of this bug. ***
Comment 13 Adeodato Simó 2004-11-23 07:32:01 UTC
This is also reported in Debian: http://bugs.debian.org/282146 [need to repeat here since #76686 has been closed, sorry].
Comment 14 Stephan Kulow 2004-11-23 10:43:10 UTC
*** Bug 57089 has been marked as a duplicate of this bug. ***
Comment 15 Stephan Kulow 2004-11-26 16:37:47 UTC
Created attachment 8455 [details]
trying to fix 

I played a lot with this patch and I'm still not convinced this is the right
thing to do. It fixes mutt.org and it makes sure web pages only defining a
background still show something reasonable. 

But e.g. http://finance.yahoo.com/q/bc?s=NOVL looks like shit in CDE color
scheme, but there is nothing I can do about within reasonable efforts. The
only option I can offer is to disable following system colors. Try it out.
Comment 16 Daniel Solaz 2004-11-26 21:02:32 UTC
regarding comment #12, please see comment #7 for bug 76686, which (IMO) is NOT a duplicate of this one
If, once system settings are honored by khtml, some Yahoo page looks bad, then it's the page author's fault for not defining colors consistently.  Bug 76686 is about honoring system settings, this one is about working around incomplete color settings in web pages.
Comment 17 Stephan Kulow 2004-11-28 16:02:15 UTC
the bugs are not independent of each other. #76686 happens because of incompletely following system colors. We used to follow only with foreground -> white/white and now we follow only with background -> black/black. My patch tries to fix this. But following system colors doesn't really help you as just too many web pages don't care.
Comment 18 Nix 2004-12-05 18:49:43 UTC
That patch doesn't work for me: it references a function `setBaseColor()' which I can't find in the DocumentImpl or any superclasses in release 3.3.2 or in HEAD (and this bug is definitely still present in 3.3.2; I'm experiencing the `foreground colour in system colours not mapped to stylesheet' variant, with an added dash of all-user-stylesheets-ignored to make it even more aggravating).

What am I missing?
Comment 19 Stephan Kulow 2005-02-04 10:29:27 UTC
*** Bug 98533 has been marked as a duplicate of this bug. ***
Comment 20 Stephan Kulow 2005-02-14 17:24:36 UTC
*** Bug 60555 has been marked as a duplicate of this bug. ***
Comment 21 Leo Savernik 2005-02-14 18:15:37 UTC
*** Bug 80062 has been marked as a duplicate of this bug. ***
Comment 22 Alex Turbov 2006-03-05 18:36:02 UTC
Another affected page (which is _ignore_ foreground color) of currently configured scheme: http://www.boost.org/libs/utility/enable_if.html
--
DAMN IT ALL! How long this nasty bug will be in KDE!!!!! 3.5.1 Still affected!!
Comment 23 J. Becker 2006-03-05 22:56:59 UTC
Why not just expect that users will use a custom style sheet for Konqueror if they wish to change colors and only change SYSTEM colors, not Konqueror colors.

Personally, I'd rather have a page be legible and in the wrong color scheme. This seems like such a thorny issue to have (especially with so many badly written sites that specify a text or background color but not both) that it's not really solvable.

One more tip. If you DO run into a site where you just can't read it, hit control-A to select all. This will force the colors into the highlight scheme, which should be legible unless you screwed those up.

Also, (and this is what I did with the Dusky color scheme: http://www.kde-look.org/content/show.php?content=7832 ) make the default text color a medium color -- not light or dark. That way you'll be able to read it on either background. Of course, this is easier said than done, since you'll probably want to go closer to either light or dark. (reading text that has lower contrast than it should is somewhat challenging.)
Comment 24 Jonathan M Davis 2007-04-14 01:15:21 UTC
Okay, it's a given that various sites are going to be poorly designed such that if you're using colors other than black text on a white background they are not going to look good. I'm unaware of any fix for this other than shooting all of the web developers who do that (but for better or worse that's not legal....).

The main problem I see is what was reported in bug #76686 (which was unfortunately closed and marked as a duplicate of this bug). Konqueror does not follow the system colors when no colors are specified by the web page. I have a dark blue background with light blue text as my system colors, but I consistently get black text on my dark blue background on web pages where the person who designed the page did not specify the color of either the text or the background.

If Konqueror is going to set the background to match my background when the background color isn't specified by the page, why isn't it also using my text color when the page doesn't define the text color? Either it should ignore the system colors entirely (not desirable) or it should use the system colors when the page doesn't define the colors.
Comment 25 richard missenden 2007-04-20 09:29:05 UTC
Why can't konqueror just do what I tell it to?

If I want white text on a black background that's what I should get, unless the page itself overrides. If the page is badly written it will show, and that is the fault of the web author, and not the responsibility of konqueror. 

If you want to work around that, add a config option for using either (1) the system colours or (2) special fg/bg colours for web pages. Maybe also a check box in (1) for 'except when the page specifies only one of fg+bg'. That way I can at least have the rest of my kde apps look how I want (without having to use firefox for web browsing!). Other browsers have done this for years now.

I tried hacking the source myself, but I just got totally lost in all the framework gubbins and couldn't see what was actually going on.
Comment 26 Leo Savernik 2007-04-20 17:33:33 UTC
What's actually impeding the Right Way (tm) to solve this problem? Hardcode 
black on white by default (ignoring colour scheme) to make the internet 
experience for the typical user as seamless as possible, and provide the 
option to use system colours as done by Coolo's patch.

I really can't understand why *by default* we hardcode one colour (fg) but 
leave the other one (bg) to be defined by the underlying colour scheme.
Comment 27 J. Becker 2007-04-20 19:11:48 UTC
Workaround: you actually can force an override with a modified
accessibility stylesheet, but this IS still a bug.

richard missenden wrote:
[bugs.kde.org quoted mail]
Comment 28 Jure Repinc 2007-12-28 17:40:11 UTC
There are still problems with text and background colors in Konqueror KDE 4 RC2+. For example try to use the Obsidian Coast color scheme which is dark and visit many pages.
Comment 29 Congyi Wu 2008-02-18 21:26:41 UTC
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.
Comment 30 Santtu Pajukanta 2008-02-25 00:59:21 UTC
> ------- Additional Comment #26 From Leo Savernik 2007-04-20 17:33 -------  
> What's actually impeding the Right Way (tm) to solve this problem? Hardcode 
> black on white by default (ignoring colour scheme) to make the internet 
> experience for the typical user as seamless as possible, and provide the 
> option to use system colours as done by Coolo's patch. 
> 
> I really can't understand why *by default* we hardcode one colour (fg) but 
> leave the other one (bg) to be defined by the underlying colour scheme. 

I support this. One could argue it's the whole half of the Web that's broken with assuming everyone has black colours on white background by default and not setting the background colour along with the foreground, but it's a whole lot less inertia to fix (*cough*) Konqueror to act like other major browsers than to fix the Web.
Comment 31 Jure Repinc 2008-04-10 13:09:44 UTC
This is still a problem with Konqueror 4 from trunk (kdelibs r, kdebase r). Another testcase can be my simple website: http://jlp.holodeck1.com/

It is also a problem for us in KDE Edu. We're using KHTML part in Step physics simulator for contextual help and it is hard to read if a user uses a dark color scheme.

So I think the best solution for this would be to have all colors in KHTML part to follow the system color scheme so that it can look consistent when integrated into apps like Step. And then there should be an option to enable web compatibility mode for KHTML part so that web browsers like Konqueror could enable it and the background would be hardcoded to white and text to black.
Comment 32 Jure Repinc 2008-04-10 13:11:09 UTC
Oh forgot to add revisions in my previous comment: kdelibs r795429, kdebase r795176
Comment 33 Alan Braslau 2008-06-04 16:08:55 UTC
I'm having a hard time accessing http://bugs.kde.org under konqueror!
Trying many different color schemes (including default), the text entry regions are not outlined so I have to guess (or remember) where they are, selection boxes are transparent unless I select or deselect them, etc.

I WANT to use konqueror, but many, too many websites are unusable so my patience is getting tried.
Comment 34 Tommi Tervo 2008-06-04 16:23:30 UTC
Re #33: see http://bugs.kde.org/show_bug.cgi?id=157850
Comment 35 gdiffey 2008-07-02 07:53:34 UTC
This is biting me for form elements using konqueror. dropdown lists and textboxes have black text on grey backgrounds. when using the obsidian color style.

KDE 4.0.84-1 debian svn 20080625
Comment 36 Peter Lewis 2008-08-07 12:07:59 UTC
This bug is still present in 4.1.0, and effectively makes dark colour schemes like Obsidian Coast "broken".

I'd like to support the idea that Konqueror / KHTML should honour the system settings and have whichever colour I choose from the colour scheme. If websites or accessibility stylesheets want to override, then that's fine.

This really is a showstopper for anyone using a dark background.

Thanks.
Comment 37 Peter Lewis 2008-08-07 12:37:02 UTC
Hi again, I just tried Congyi Wu's workaround to make my konqueror backgrounds white (which I really don't want to do, but it's the only thing to make it work right now, I guess), and I thought I'd add that you'll also need to replace all the instances of:

background-color: window;

with

background-color: white;

in the various form sections lower down the html4.css file. Otherwise, even this page looks terrible in Obsidian, as you're entering black text into a dark grey box to make comments :-/

HTH, but looking forward to a "proper" solution soon :-)
Comment 38 Lars Ivar Igesund 2008-11-26 15:46:59 UTC
Bug 170919 is probably a duplicate.
Comment 39 Alex Turbov 2008-11-27 12:37:45 UTC
I just want post a link that still affected by this bug (some of them posted above are not valid already)
http://www.gnu.org/software/autoconf/manual/make/
Comment 40 Peter Lewis 2008-11-27 14:36:24 UTC
Indeed.

BTW - I've made my html4.css available for download here:
http://www.petesodyssey.org/files/html4.css

...to be placed into ~/.kde/share/apps/khtml/css/ in order to work-around this bug for now and make pages readable.

Still hoping for a konqueror that does what it's told though... :-)
Comment 41 Lars Ivar Igesund 2008-11-27 16:15:17 UTC
(In reply to comment #40)
> Indeed.
> 
> BTW - I've made my html4.css available for download here:
> http://www.petesodyssey.org/files/html4.css
> 
> ...to be placed into ~/.kde/share/apps/khtml/css/ in order to work-around this
> bug for now and make pages readable.
> 
> Still hoping for a konqueror that does what it's told though... :-)
> 

This is well and fine enough for the background, but do still not handle the serious issues referred to in my post in Bug 170919 which relates to the colours used in themed widgets (the biggest problem is forms, but for instance black scrollbars (like I see in this particular form) just look ugly when the page was designed with light widgets in mind.
Comment 42 Peter Lewis 2009-01-06 16:56:38 UTC
Hmm... something seems to have changed at least in 4.1.3 or later.

BTW, I've noticed from my playing around with the html4.css that I don't seem able to override the text colour for text input areas any more. They seem to be hard-coded as view-text, though the background isn't. Can someone confirm that khtml overrides html4.css with text colour for text input form items?

Thanks.

BTW, there's a really easy way of seeing this brokenness in action- select obsidian coast as a your scheme, then try to write a comment on this very page :-(
Comment 43 Teruel deCampo MD 2009-01-31 22:52:38 UTC
http://www.ridingwithrobots.org/blog/?p=1616

This is the site that is pointed by the plasmoid ridewithrobots. It is all black.
If I go to File/open with Konqueror/kde3 it works OK. The same with Firefox. 
It seems to be the same problem. If not I will start another bug report.
Comment 44 FiNeX 2009-09-08 14:13:50 UTC
*** Bug 170919 has been marked as a duplicate of this bug. ***
Comment 45 FiNeX 2009-09-08 14:13:55 UTC
*** Bug 200253 has been marked as a duplicate of this bug. ***
Comment 46 FiNeX 2009-09-08 14:18:28 UTC
*** Bug 203797 has been marked as a duplicate of this bug. ***
Comment 47 FiNeX 2009-09-08 14:18:59 UTC
*** Bug 175922 has been marked as a duplicate of this bug. ***
Comment 48 FiNeX 2009-09-08 14:19:36 UTC
*** Bug 172534 has been marked as a duplicate of this bug. ***
Comment 49 FiNeX 2009-09-08 14:20:00 UTC
*** Bug 160165 has been marked as a duplicate of this bug. ***
Comment 50 FiNeX 2009-09-08 15:12:21 UTC
*** Bug 53885 has been marked as a duplicate of this bug. ***
Comment 51 FiNeX 2009-09-19 21:16:59 UTC
*** Bug 207875 has been marked as a duplicate of this bug. ***
Comment 52 FiNeX 2009-09-19 21:19:35 UTC
Look bug #207875 for some additional details.
Comment 53 Christophe Marin 2009-09-26 11:33:58 UTC
*** Bug 207906 has been marked as a duplicate of this bug. ***
Comment 54 Arne Babenhauserheide 2009-11-15 22:49:34 UTC
I just found this bug when I wanted to post one for the topic myself. 

I would prefer to have an option to override the default text color of websites which don't supply a custom background color. 

I'm also browsing with dark background, and I don't want Konqueror to break my theme (theme: http://draketo.de/licht/freie-software/kde/kde-433 ). 

I didn't realize until I found this bug that the websites didn't supply a default text color - I assumed they defined black for text. 

So the straightforward solution I see is to make Konqueror honor my colorscheme - I set it for a reason, after all. 

The complex solution would be to honor the colorscheme, but to have an option to make Konqueror check for each custom text color if its contrast to the according background is high enough, and to use a color with more contrast if the custom color isn't visible/readable.
Comment 55 peyotll 2010-01-22 19:24:40 UTC
Why is there black themes in KDE if we can't use them???
I tried obsidian theme and can't go back now, I really love It.
I hope that bug will be corrected.
Comment 56 Jörg Walter 2010-11-26 11:25:01 UTC
This bug still exists. As a workaround for dark-background lovers, you can edit

/usr/share/kde4/apps/khtml/css/html4.css

and replace

color: -khtml-text;

with

color: white;

This will affect all users on the machine, though, so a real fix is still needed.
Comment 57 Michael Tsang 2010-12-11 13:56:56 UTC
This bug STILL exists in 4.4.5! I have to use a custom stylesheet to override it.
Comment 58 Alex Turbov 2010-12-11 16:34:31 UTC
(In reply to comment #57)
> This bug STILL exists in 4.4.5! I have to use a custom stylesheet to override
> it.

Yep! Its about 7 years old bug!! Anniversary coming soon :)
Comment 59 Samuel Brack 2010-12-31 16:14:44 UTC
Updated it to version 4.4.5
Comment 60 Michael Tsang 2011-01-26 10:03:21 UTC
I think that the best is to follow the system settings for background, text and links in terms of colour, font and size unless the page overrides it.
Comment 61 Tommi Tervo 2011-05-19 12:22:49 UTC
*** Bug 226437 has been marked as a duplicate of this bug. ***
Comment 62 Tommi Tervo 2011-05-19 12:23:08 UTC
*** Bug 273630 has been marked as a duplicate of this bug. ***
Comment 63 Christopher Yeleighton 2011-05-19 12:46:38 UTC
My solution:

BODY { COLOR: WINDOWTEXT } :LINK { COLOR: AQUA }
Comment 64 Christopher Yeleighton 2011-07-01 20:41:33 UTC
(In reply to comment #29)

> KDE has base css files in /usr/share/apps/khtml/css/html4.css and 
It is at /usr/share/kde4/apps/khtml/css/html4.css
Comment 65 Christopher Yeleighton 2011-07-01 21:01:46 UTC
It also turns out that Konqueror ignores any custom styles for TEXTAREA.
Moreover, the custom style sheet is not applied in WebKit mode and I still get black on dark there.
Comment 66 Christopher Yeleighton 2011-07-02 14:32:52 UTC
(In reply to comment #65)
> It also turns out that Konqueror ignores any custom styles for TEXTAREA.

As weird as it sounds, TEXTAREA got updated after restart.
Comment 67 Christopher Yeleighton 2011-07-07 17:17:14 UTC
(In reply to comment #63)
> My solution:
> 
> BODY { COLOR: WINDOWTEXT } :LINK { COLOR: AQUA }

Unfortunately, putting those declarations into custom CSS for Konqueror does not affect the display of embedded documents such as Ark Preview.
Comment 68 Tommi Tervo 2011-12-28 20:10:12 UTC
*** Bug 169701 has been marked as a duplicate of this bug. ***
Comment 69 Felix Tiede 2014-04-18 09:24:59 UTC
Created attachment 86145 [details]
Patch to use theme's text color unless page's css selects otherwise

This patch uses the theme's foreground color for text, unless the displayed page defines another textcolor. It fixes display of basic HTML pages without any stylesheet yet links are IMHO still too dark and probably need the same fix.

Since there are pages in the web which set textcolor but no background (apparently simply relying on the assumption that such pages are displayed with a white background a more complete patch could examine a page, try to figure if textcolor is set, while background is not and in that case switch to white background.
Or, even simpler, use white background as default and leave textcolor as-is (and annoy users with black color background themes ;) ).
Comment 70 Michael Tsang 2015-03-02 11:42:46 UTC
This still exists in KDE 4.14.1 as in 2014! More than 12 years already!
Comment 71 Michael Tsang 2015-03-02 11:44:52 UTC
Created attachment 91374 [details]
Improper default colour in Konqueror

This shows the improper default colour in KDE. I am using the produkt colour scheme, but both rendering engine does not get all the colours right, leaving some unintelligible combination.
Comment 72 Christoph Cullmann 2024-05-06 20:58:10 UTC
Dear user,

KHTML (and KJS) was a long time more or less unmaintained and got removed in KF6.

Please migrate to use a QWebEngine based HTML component.

We will do no further fixes or improvements to the KF5 branches of these components beside important security fixes.

For security issues, please see:

https://kde.org/info/security/

Sorry that we did not fix this issue during the life-time of KHTML.

Greetings
Christoph Cullmann