Template talk:Diagonal split header

Accesibility
It' should be noted that this creates an accessibility issue. A user who has to rely on HTML instead of visual information will not be able to interpret this information easily. —Th e DJ (talk • contribs) 09:27, 7 July 2017 (UTC) to reply to me 11:03, 7 July 2017 (UTC)
 * Is there an easy solution for this? The best thing I can think of is adding a title attribute for the column header and the row header, as it wouldn't be possible to put the gradient under multiple different cells. Example 2 in the doc looks problematic, as the template isn't actually being used as a header in any of the cells. Jc86035 (talk) Use &#123;&#123;re&#124;Jc86035&#125;&#125;

I have not figured out an easy solution to this so far. title attributes are generally ignored in most situations by screenreaders. Maybe an aria-label can work, but the language is the hard part here. How do you describe this to a person who can't see, using rather generic language ? Take the first example of the Template. You'd now have: That's just VoiceOver, and each screenreader might do it differently Now say we put aria-label "Row headers are: From" and "Column headers are: To". You'd get So what do you put in the aria-label (so what sentence do you replace To with), which will describe to someone what it is ? Best i can come up with so far is: But we will need to apply some HTML stripping etc on the titles, because currently it allows br tags and full template calls, and you cannot put that into an element attribute. —Th e DJ (talk • contribs) 13:25, 7 July 2017 (UTC)
 * "To, From. Column 1 of 4" if you navigate to it. And "To, From" when ever you request a column or row header description from a cell that it is the header of.
 * "column headers indicate "To", row headers indicate "From", Column 1 of 4.

Diagonal split color box
Discussion at Wikipedia_talk:Manual_of_Style/Accessibility AngusWOOF  ( bark  •  sniff ) 21:51, 17 September 2019 (UTC)

Compatibility with legacy browsers
Can you add  between   and   to this template. Chrome 10 to 25 and Safari 5.1 to 6.0 requires -webkit- prefix, Firefox 3.6 to 15 requires -moz- prefix and Opera 11.1 to 12.0 requires -o- prefix for linear gradients. 185.69.144.90 (talk) 09:45, 3 November 2022 (UTC)
 * ❌ these browsers are too old to justify providing special coding provision. See Browser support. -- Red rose64 &#x1f339; (talk) 20:57, 3 November 2022 (UTC)

Alternative technique for consistent line thickness
It has peeved me for a while that the diagonal line produced by this template is somewhat thicker than the table cell border, which is especially visible when the cell is large.

I've come up with an alternative technique, using a SVG background-image to draw the line: Template:Diagonal split header/sandbox

An example of the problem it solves can be seen here: Template:Diagonal split header/testcases

However, with this approach we can't set separate background colors for the split cell (Template:Diagonal split header), because background-images are only allowed in TemplateStyles (not in inline CSS), and there's no way to pass the color as a parameter to TemplateStyles. Unless there's some clever trick I am missing, these would have to keep using the old technique.

It may also have slightly different browser support, although so far it worked on everything I tested. In theory, SVG in CSS backgrounds is supported by more old browser versions than gradients in CSS backgrounds: https://caniuse.com/svg-css https://caniuse.com/css-gradients

Thoughts? Matma Rex talk 16:50, 23 January 2023 (UTC)


 * Thanks, Matma Rex, and nice work! I think the separate background colors feature would be a small proportion of the usage cases but worth keeping, if possible.


 * The line thickness issue with the existing template is a hard-coded percentage is used for the linear gradient color-stops:




 * In this case, the diagonal line width is (50.5 − 49.5) = 1.0% of the gradient axis length. This results in a thinner line for small cells and a thicker line for large cells.


 * Playing around with (or even calculating) the color-stop values could resolve the issue. One way might be to add an extra parameter to control line thickness. The example code below uses a simple switch to select from four pre-canned options (probably good enough for most cell sizes – and with less computational overhead than generating precise numbers):

Partial code

style="background:#EAECF0;{{#switch: {{{5}}} {{divhide|end}}
 * 1 = background:linear-gradient(to top right,#EAECF0 49.75%,#AAA 49.90%,#AAA 50.10%,#EAECF0 50.25%);
 * 2 = background:linear-gradient(to top right,#EAECF0 49.55%,#AAA 49.80%,#AAA 50.20%,#EAECF0 50.45%);
 * 3 = background:linear-gradient(to top right,#EAECF0 49.20%,#AAA 49.70%,#AAA 50.30%,#EAECF0 50.80%);
 * default = background:linear-gradient(to top right, #EAECF0 48.5%, #AAA 49.5%, #AAA 50.5%, #EAECF0 51.5%);

{{clear}}
 * {| class="wikitable" style="float: left"

!style="background:#EAECF0;{{#switch: {{{5}}} ! A cell ! A cell = 1.0% of gradient axis
 * 1 = background:linear-gradient(to top right,#EAECF0 49.75%,#AAA 49.90%,#AAA 50.10%,#EAECF0 50.25%);
 * 2 = background:linear-gradient(to top right,#EAECF0 49.55%,#AAA 49.80%,#AAA 50.20%,#EAECF0 50.45%);
 * 3 = background:linear-gradient(to top right,#EAECF0 49.20%,#AAA 49.70%,#AAA 50.30%,#EAECF0 50.80%);
 * default = background:linear-gradient(to top right, #EAECF0 48.5%, #AAA 49.5%, #AAA 50.5%, #EAECF0 51.5%);}}line-height:1.2;padding:0.1em 0.4em;"|
 * Diagonal line thickness
 * }

{{clear}}
 * {| class="wikitable" style="float: left"

!style="background:#EAECF0;{{#switch: 3 ! A large cell ! A large cell = 0.6% of gradient axis
 * 1 = background:linear-gradient(to top right,#EAECF0 49.75%,#AAA 49.90%,#AAA 50.10%,#EAECF0 50.25%);
 * 2 = background:linear-gradient(to top right,#EAECF0 49.55%,#AAA 49.80%,#AAA 50.20%,#EAECF0 50.45%);
 * 3 = background:linear-gradient(to top right,#EAECF0 49.20%,#AAA 49.70%,#AAA 50.30%,#EAECF0 50.80%);
 * default = background:linear-gradient(to top right, #EAECF0 49%, #AAA 49.5%, #AAA 50.5%, #EAECF0 51%);}}line-height:1.2;padding:0.1em 0.4em;"|
 * Diagonal line thickness
 * }

{{clear}}
 * {| class="wikitable" style="float: left"

!style="background:#EAECF0;{{#switch: 2 ! A very, very large cell ! A very, very large cell = 0.4% of gradient axis
 * 1 = background:linear-gradient(to top right,#EAECF0 49.75%,#AAA 49.90%,#AAA 50.10%,#EAECF0 50.25%);
 * 2 = background:linear-gradient(to top right,#EAECF0 49.55%,#AAA 49.80%,#AAA 50.20%,#EAECF0 50.45%);
 * 3 = background:linear-gradient(to top right,#EAECF0 49.20%,#AAA 49.70%,#AAA 50.30%,#EAECF0 50.80%);
 * default = background:linear-gradient(to top right, #EAECF0 49%, #AAA 49.5%, #AAA 50.5%, #EAECF0 51%);}}line-height:1.2;padding:0.1em 0.4em;"|
 * Diagonal line thickness
 * }

{{clear}}
 * {| class="wikitable" style="float: left"

!style="background:#EAECF0;{{#switch: 1 ! A very, very, very, very, very, very large cell ! A very, very, very, very, very, very, very, very, very, very, very large cell = 0.2% of gradient axis {{clear}}
 * 1 = background:linear-gradient(to top right,#EAECF0 49.75%,#AAA 49.90%,#AAA 50.10%,#EAECF0 50.25%);
 * 2 = background:linear-gradient(to top right,#EAECF0 49.55%,#AAA 49.80%,#AAA 50.20%,#EAECF0 50.45%);
 * 3 = background:linear-gradient(to top right,#EAECF0 49.20%,#AAA 49.70%,#AAA 50.30%,#EAECF0 50.80%);
 * default = background:linear-gradient(to top right, #EAECF0 49%, #AAA 49.5%, #AAA 50.5%, #EAECF0 51%);}}line-height:1.2;padding:0.1em 0.4em;"|
 * Diagonal line thickness
 * }
 * This might be an option to tweak the existing linear-gradient technique and retain the color functionality? -- Ham105 (talk) 22:31, 23 January 2023 (UTC)

{{od|2}} I probably could have added one more option for 0.8% of gradient axis length. -- Ham105 (talk) 22:37, 23 January 2023 (UTC)


 * This works too, although it's a bit more effort to use. Meanwhile I came up with a way to restore support for backgrounds with the new technique: Template:Diagonal split header/testcases. I was quite happy at first, but then I noticed it causes some funniness with the table cell borders on Firefox, so that might not be good enough. Matma Rex talk 09:29, 24 January 2023 (UTC)

I've moved my original version to a separate template: Template:Diagonal split header 2 and updated the documentation. Matma Rex talk 00:53, 24 February 2023 (UTC)

calc
I was testing calc in the diagonal split header sandbox and it works consistently across large cells, with consistent line thickness. The calc property works in all Grade C browsers. Here is a list: Can it be added to the template instead of 49%, 49.5%, 50.5% and 51%? Xeverything11 (talk) 16:13, 3 May 2024 (UTC)
 * It's not a property, [//www.w3.org/TR/css-values-3/#calc-notation it's a function]. All valid CSS declarations have the format property:value (each surrounded by optional whitespace), so in the declaration    is the property. Anyway, CSS Values and Units Module Level 3 is a W3C Candidate Recommendation Draft (as of 22 March 2024), so it's not yet been accepted as a formal W3C Recommendation, so should not be relied on. -- Red rose64 &#x1f339; (talk) 18:22, 3 May 2024 (UTC)