Forum Bugs

CSS element selectors don't appear to be working

apoco
Recently, I noticed that styles in my element selectors were not being processed. For example these styles were not getting processed:

p
{
    font-size: 8pt;
    margin-top: 1em;
}


I tried changing the tag name so it was uppercase, and that also didn't work. However, giving my paragraphs a CSS class and using a class selector works fine. The same problem occurred with my body selector. Is this behavior to be expected, or am I doing something wrong?
mikeday
That's odd, there should be no problems with element selectors. Are you using namespaces in your input document, or your style sheet?
apoco
mikeday wrote:
Are you using namespaces in your input document, or your style sheet?


I'm using "http://www.w3.org/1999/xhtml" for my default namespace, i.e:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  ...
</html>


I'm not using any in the style sheets.
mikeday
That should be fine, for example try this document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<p>This is a test.</p>
</body>
</html>

With this style sheet:
p { color: red }

And you should see a red paragraph.
apoco
I believe I found the issue, and it's pretty annoying. My "p" selector was the first item in the file. If I put a line break or even a space before it, it started to work. That made me suspicious that this was all due to the UTF-8 BOM. Sure enough, once I saved my CSS file without the BOM, the selector worked correctly. The strange thing is that the class selectors appearing at the top of BOM CSS files have been working fine.

Unfortunately, Visual Studio by default encodes all of its text files as UTF-8 with a BOM. At least there appears to be a workaround.
mikeday
Can you email me (mikeday@yeslogic.com) the style sheet that is causing problems? Prince should be skipping the UTF-8 BOM character if it occurs at the start of a style sheet file.
apoco
mikeday wrote:
Can you email me (mikeday@yeslogic.com) the style sheet that is causing problems?


Sent. I should mention that the Prince is downloading the style sheets via HTTP, in case that makes a difference.
mikeday
This is a bug in Prince, where if the UTF-8 BOM is immediately followed by an identifier the whole thing will be parsed as one invalid identifier. If it is followed by whitespace or punctuation, then the BOM will be separately recognised as such. We will fix this bug in the next release of Prince. Thanks for letting us know about the issue! :)
mikeday
This bug has been fixed in Prince 7.1, available now. Thanks for letting us know about the issue. :)