- From: Bert Bos <bert@w3.org>
- Date: Fri, 2 Dec 2011 12:42:39 +0100
- To: W3C style mailing list <www-style@w3.org>
On re-reading the documentation of the template layout implementation in HTMLayout by Andrew Fedoniouk and Ivan Goroun (http://www.terrainformatica.com/w3/flex-layout/flex-layout.htm) I noticed something that I hadn't seen before; or maybe seen but forgotten: The template syntax allows numbers as a shortcut for simple (but probably common) cases. E.g. if you have a document like this <BODY> <DIV>North...</DIV> <DIV>West...</DIV> <DIV>East...</DIV> <DIV>South...</DIV> you could write this layout: BODY { display: ". 1 ." "2 . 3" ". 4 ." } instead of the equivalent: BODY { display: ". a ." "b . c" ". d ." } DIV:nth-child(1) { position: a } DIV:nth-child(2) { position: b } DIV:nth-child(3) { position: c } DIV:nth-child(4) { position: d } I.e., the numbers refer directly to the children of the template element. The designated children are automatically positioned in the given slot, without having to write any rules for them. Advantages: - No need to invent names for the slots in the template. - Shorter: avoids extra rules and selectors with pseudo-classes. Disadvantages: - An extra thing to learn. - Spaces between slots in a templates are required (rather than optional), because numbers can have more than one digit. Clearly, this shortcut is limited to positioning child elements (not other descendants), and to slots with at most one element in it. You still need named slots for the other cases. So the question is, do the advantages outweigh the disadvantages? Bert PS. Tracker code: ISSUE-201 http://www.w3.org/Style/CSS/Tracker/issues/201 -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Friday, 2 December 2011 11:43:13 UTC