If you are talking about the title attribute in the following html then css has no way of styling it. It’s down to the browser entirely and we have no access to it.
You can’t change the browser tooltip assuming that’s what you mean. You just remove the title attribute and then you don’t get any tooltip.
However in my browser the tooltip is black text on a white background
Unless of course you have some sort of JS plugin that is removing the titlle attribute and providing a css tooltip version of its own. However that is not evident in the codepen you posted.
Do you have a codepen demo that shows the black background and whit text?
That codepen shows no tooltip at all and there is no title attribute on the header cart icon that I can see. Can you post a screenshot of that actual codepen with the tooltip showing?
I think you may be looking at a local version which is running some js that is not in the codepen.
There are 3 of us here now who can’t see the tooltip you mention so there is something strange going on.
I tested in Chrome and Mozilla/Firefox and when I manually add the cart title they show as a white background with black text (I’m assuming that perhaps if you had dark mode selected that would be reversed).
As I said above that unless this is a js enhanced tooltip then it is not possible to change the browser’s default tooltip appearance. It’s impossible which is why some people write their own tooltips instead of the default ones but that is quite complicated to get right.
Ok I can see the tooltip now but its still a white background with black text on all my browsers.
The only thing I can think is that you have dark mode enabled on your browser by default but it doesn’t look like it as the other elements would change also.
I’m a bit mystified but as I mentioned before if this the default title attribute tooltip then you are stuck with it.
Maybe @Archibald or one of the others here can take a look and see if they see any different.
You don’t want to do that because tooltips are used for accessibility purposes. Taking them away could potentially drive business away.
This might be a scenario where you need to ignore the little things for the big picture since it’s not something covered in the css spec. There are ways around it, but I’m not sure it’s worth the effort of working it out just to make the tool tip look pixel perfect.