Re: CSS Referencing

On 5 January 2012 17:18, Matthew Wilcox <elvendil@gmail.com> wrote:
> @Jon
>
> That's fine in the context of a grid. But that is incredibly limiting
> - I have to have a grid and it's only about layout. I may not want a
> grid, it may not make any sense for my design, and my problem may not
> be a layout problem. Maybe I want to match colours, or font sizes,
> etc.

If you want to share colours, font sizes, etc, why can't you just use
CSS classes? It seems like we already have mechanisms to easily share
property values like colours and font sizes between elements. These
could be improved, but I think LESS and SASS style variables and
mixins would be a much better addition.

This referencing idea seems analogous to the goto keyword in
programming languages. It would provide a quick and easy way to point
one property to another, but the end result would likely be a horrible
spaghetti of cross referencing that would be very difficult to
understand and reason about. Programmers have learned through painful
experience that's what needed is a structured way to express and
abstract these kinds of dependencies.

Indeed, CSS is all about abstracting the common styling of elements
into discrete, reusable classes. Instead of just saying, have this
element act like this other element, you take what is common about the
two and express it as a class that you can reuse. Switching to a
mechanism where elements arbitrarily reference the properties of other
elements seems like a step away from abstraction and reuse to ad-hoc
messiness.

> I think the idea that grid answers the same problem as CSS Refernecing
> would be shoe-horning very specific sub-sets of one concept into
> fitting a given other framework. They're not the same problem.

I'm not convinced there is a problem, outside of layout. I can't
remember any occasion where I wanted some element to pick up the same
background-color or font-size as another element, but where I couldn't
just introduce a CSS class. Could you provide a use case, other than
for layout, where you think this kind of referencing would be useful?

> Also, having looked at the grid specification, I remain dubious as to
> how successful it will be with authors. The syntax is hard and
> unfamiliar. With that said, I am reading a spec, which is not the same
> as reading a clear explanation - so it may be simpler than it looks.

I'd recommend checking out some tutorials and examples. I don't think
it's as difficult as you imagine. I know Microsoft have some decent
documentation and examples for Grid Layout, for example[1]. Also, the
ideas in there are not novel, they're evolutions of similar approaches
used in UI toolkits like Microsoft's Silverlight and WPF, and Java's
Swing, and they've proved to be effective and understandable for users
of those technologies.

>
> What I like about CSS getting calc(), and constants is it allows us to
> define our own units and build our own grids with the existing layout
> tools.
>
> gridUnit = 24px;
>
> div#one { width: calc(6*gridUnit); }

[1] http://blogs.msdn.com/b/ie/archive/2011/04/14/ie10-platform-preview-and-css-features-for-adaptive-layouts.aspx
http://ie.microsoft.com/testdrive/HTML5/Griddle/Default.html
http://msdn.microsoft.com/en-us/library/hh673533.aspx

Received on Thursday, 5 January 2012 20:30:22 UTC