(Blogger had nasty issues with updating their software, so a number of blogs were in read-only mode and so instead of writing this up I was occupied with other things. The good thing is that Blogger have been very responsive in addressing the posting outage.)
When tallying personal data and opinions for what was ostensibly a list of items in a text file, I wanted to find out how in an ordered HTML list (a numbered list with
<OL>
tags) I'd be able to use Cascading Style Sheets (CSS) to place some special items before counters (usually numbers, but CSS 2 standard has expanded counters to be much more) as markers of some sort.The main point was to make a more informative and interesting list... Well, yes, but this turned out to be a far more difficult exercise than I first thought.
For an intro, the following describes the differences in rendering between Mozilla Firefox 2 and Mozilla Firefox 3+. Because these browsers use the Gecko rendering engine, which is used by other browsers, then here's also a quick browser side-by-side of the rendering engine's branches:
Gecko 1.7 | Gecko 1.8.1 | Gecko 1.9 and newer |
Mozilla Firefox 1.0 | Mozilla Firefox/IceWeasel 2 | Mozilla Firefox/IceWeasel 3+ |
Mozilla Application Suite 1.7 | SeaMonkey 1.1 | SeaMonkey 2+ |
K-Meleon 1.5 | K-Meleon 1.6+ |
What follows is example CSS code with some comments. I haven't yet had all the time to describe everything, but bear in mind the lede.
Moreover, the list already contains tabular data; including informative content withOL.Eurovisioon {counter-reset:item; list-style-position:outside}
OL.Eurovisioon LI {display:block;}/*
•display:block
^ loses the browser's automatic numbering;
• The items must be displayed as block, so as to make sure that the later width attribute applies.*/
OL.Eurovisioon LI:before {float:left;
content:'miskitekst\ ' counter(item) '.'; counter-increment:item; border:solid 1px gray; padding-right:5px; width:82px; text-align:right; line-height:1.1em; color:navy; white-space:nowrap}/* these work... */ /*
^ • Floating them left makes sure that the items are displayed like in a standard ordered list;
•item
must be insidecounter()
,item
is also specified forcounter-increment
;
•text-align:right
aligns numbered counters right and so makes it more list-like again;
•white-space:nowrap
makes sure that when increasing text size, text inside blocks wouldn't wrap and add in height and take away from the structure.
Caveats:
Once the items are all displayed astext-block
orinline
, thewidth
attribute does not apply anymore. Displaying asblock
and floating to right works in Firefox 4 (I'm also assuming 3.0+), but not in SeaMonkey 1.1 and anything with the Gecko 1.8.1 engine (see the above table) and the caveat applies to all older browsers.). Setting thedisplay
totext-block
orinline
fixes the issues in SeaMonkey 1.1, only that settingwidth
attributes does not work then.*/
OL.Eurovisioon > LI.plus:before {width:82px;
/* somehow works */content:'\ sisu\ ' counter(item) '.\ '; text-align:right; color:blue}OL.Eurovisioon > LI.plus {list-style-position:outside}
^ Is this really necessary?
:before
or :after
pseudo-classes means that this data won't be indexed and may be lost to search engines. Non-graphical and older browsers won't be able to see such content.I, of course, thought that I'd never see the day when my own fancy CSS implementation would not be visible with something like SeaMonkey 1.1.19.
The correct rendering is supported by Mozilla Firefox and IceWeasel 3 (probably since 3.0), SeaMonkey 2, Google Chrome (Version 11 does, so I'm assuming a host of earlier versions do, too), and the latest Konqueror, Apple, and Opera fare. Internet Explorer 7 does not support this. Bleh.
So here's the example list:
- tekst
- teine tekst
- kolmas tekst
- neljas tekst
<OL CLASS=Eurovisioon>
<LI>tekst</LI>
<LI CLASS=plus>teine tekst</LI>
<LI>kolmas tekst</LI>
<LI>neljas tekst</LI>
</OL>
So long I still have to use Mozilla Firefox 1.0, I must still use a simple HTML table. At least the advantage is that most browsers will be able to see the content. The table in question is here.As the information was laid out in a text file, it nevertheless turned out to be tabular data, which was actually much simpler to organise into a table, rather than implement complex CSS for the same.
1 comment:
Everything you have posted might as well be in Hebrew for me. I wish I was as smart as you!
Post a Comment