MISS­ING PAR­ENT

net magazine - - Q & AS -

Will there ever be a par­ent se­lec­tor? Martin Joiner, Bris­tol, UK CC: I re­ally hope so. I think there are plenty of real-world use cases that prove it would be a use­ful ad­di­tion to CSS. Just the other day I was in a sit­u­a­tion where I was work­ing on a tem­plate that out­put an ar­ti­cle. It was pos­si­ble any given ar­ti­cle could have meta data with some in­for­ma­tion about how that ar­ti­cle should be laid out. For ex­am­ple, meta data say­ing “hide the side­bar on this ar­ti­cle”. I needed that in­for­ma­tion in a higher-up tem­plate where I could use it on con­tain­ing HTML el­e­ments, but I didn’t have that data in those high­erup tem­plates. With a par­ent se­lec­tor, I could have done:

main: has (ar­ti­cle. no- side­bar) { /* al­ter­nate grid lay­out the ac­com­mo­dates no side­bar */ }

There is a :fo­cus-within se­lec­tor now, with im­ple­men­ta­tions in mul­ti­ple browsers, which is essen­tially a par­ent se­lec­tor. I’m not sure it proves all is­sues with par­ent se­lec­tors have been solved to the sat­is­fac­tion of browser ven­dors, but it feels like a start.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.