1, Strange formatting of <B> inside <PRE>, and 2, Unexpected formatting of bogus <D> element
FFox 112.0.2 (64-bit) running in Linux Mint 20.3 Una.
1, Strange formatting of <B> inside <PRE>. When using the default monospace font inside a <PRE> element, adding <B> elements disrupts character spacing. A screen shot is attached. "wheat" & "purple" are the colors. They are set in a CSS file. Here is the source HTML:
<PRE class="white"> // (1/240) sec-per-char +-all-strides--------------------------> <B class="wheat">24pps</B> // <B class="purple">(Aa______)(Bb______)(Cc______)(Dd______)</B> source pps <B class="wheat">_hpps(Aa..Dd)</B> // <B class="purple">(A_______)(B_______)(C_______)(D_______)</B> source top hpps // <B class="purple">(a_______)(b_______)(c_______)(d_______)</B> bottom hpps <B class="wheat">(AaBbBcCdDd)=60hpps</B> // <B class="purple">(A_-20%)(B_________+60%)(C_-20%)(D_-20%)</B> target top hpps // <B class="purple">(a_-20%)(b_-20%)(c_-20%)(d_________+60%)</B> bottom hpps <B class="wheat">]30'1.001htfps</B> // <B class="purple">[A+a___][B+b___][B+c___][C+d___][D+d___]</B> target htfps // ================ combed</PRE>
<This character spacing disruption is surely a bug.>
<2, Unexpected formatting of bogus <D> element.> elements to (bogus) <D> elements in the source HTML. The result? The colors were retained and the characters became aligned.>
<What do you think of 1 & 2? Can you test in other browsers -- I can't.>
<Thanks for Your Thoughts,> Mark.
Ndryshuar
Zgjidhje e zgjedhur
I came up with a workaround that doesn't depend on bogus elements.
I'll make all the diagrams entirely bold. Then, using a <B> element inside the diagram in order to change background-color won't screw up the vertical alignment.
Thanks for your help. Mark.
Case closed.
Lexojeni këtë përgjigje brenda kontekstit 👍 0Krejt Përgjigjet (9)
The problem statement above got slightly distorted because of formatting, but not badly. There appears to be no way to fix it. I can't find a way to edit the posting. Sorry.
You can't expect that mixing bold characters and normal spaces take the same width because bold spaces have a width that matches the width of the bold character.
Does this also happen if you include the spaces within the <b></b> tags ?
<PRE class="white"> // (1/240) sec-per-char +-all-strides--------------------------> <B class="wheat">24pps </B>// <B class="purple">(Aa______)(Bb______)(Cc______)(Dd______)</B> source pps <B class="wheat">_hpps(Aa..Dd) </B>// <B class="purple">(A_______)(B_______)(C_______)(D_______)</B> source top hpps // <B class="purple">(a_______)(b_______)(c_______)(d_______)</B> bottom hpps <B class="wheat">(AaBbBcCdDd)=60hpps </B>// <B class="purple">(A_-20%)(B_________+60%)(C_-20%)(D_-20%)</B> target top hpps // <B class="purple">(a_-20%)(b_-20%)(c_-20%)(d_________+60%)</B> bottom hpps <B class="wheat">]30'1.001htfps </B>// <B class="purple">[A+a___][B+b___][B+c___][C+d___][D+d___]</B> target htfps // ================ combed </PRE>
// (1/240) sec-per-char +-all-strides--------------------------> 24pps // (Aa______)(Bb______)(Cc______)(Dd______) source pps _hpps(Aa..Dd) // (A_______)(B_______)(C_______)(D_______) source top hpps // (a_______)(b_______)(c_______)(d_______) bottom hpps (AaBbBcCdDd)=60hpps // (A_-20%)(B_________+60%)(C_-20%)(D_-20%) target top hpps // (a_-20%)(b_-20%)(c_-20%)(d_________+60%) bottom hpps ]30'1.001htfps // [A+a___][B+b___][B+c___][C+d___][D+d___] target htfps // ================ combed
Ndryshuar
You can find "Edit this question" under the "Question Tools" menu in the sidebar. For a reply, "Edit this post" is in the three-dot menu next to a reply.
cor-el said
You can't expect that mixing bold characters and normal spaces take the same width because bold spaces have a width that matches the width of the bold character.
Pale Moon doesn't add space. It enboldens characters without taking up more space. I don't/can't run other browsers, so I don't know about them. That's why I asked users to try other browsers.
Ndryshuar
This might depend on the font that is used as some fonts may have a bold version that takes the same space as the normal version, but a bold font is usually wider than a normal font for readability. You can not know beforehand what font is used, so you need to ensure that the number of bold characters stays the same to ensure proper formatting.
cor-el said
Does this also happen if you include the spaces within the <b></b> tags ?
I tried soooooo many workarounds. Yes, I tried putting everything in <B> elements having differing colors but that provoked other problems.
When I stumbled on (bogus) <D> element that 'fixes' the problem (even though a bogus element shouldn't do anything), and it worked for both Pale Moon (in Windows) and FFox (in Linux), well, I jumpped on it. Does a bogus <D> element also work for other browsers? I don't/can't know. Do you know whether I can rely on it?
PS: Simply changing the background colors is all I need. Do you know of an HTML element that doesn't also make other changes?
Ndryshuar
Zgjidhja e Zgjedhur
I came up with a workaround that doesn't depend on bogus elements.
I'll make all the diagrams entirely bold. Then, using a <B> element inside the diagram in order to change background-color won't screw up the vertical alignment.
Thanks for your help. Mark.
Case closed.
You can use a SPAN to change the background color, so no need to use a B tag as that is meant to bold text.
cor-el said
You can use a SPAN to change the background color, so no need to use a B tag as that is meant to bold text.
Using a <SPAN> inside a <PRE> causes too many other problems. Thank you for the suggestion though. -- Mark.