Discussion:
css problems
(too old to reply)
Xah Lee
2010-01-28 16:16:54 UTC
Permalink
Wrote out some random thoughts about problems of CSS. (a blog). Any
thoughts?

-------------------------------------
(perm link with links and updates: http://xahlee.org/js/css_problems.html)

Am reading the Wikipedia article on Cascading Style Sheets again.

Here's a interesting quote:

While new additions to CSS3 provide a stronger, more robust layout
feature-set, CSS is still very much rooted as a styling language, not
a layout language. This problem has also meant that creating fluid
layouts is still very much done by hand-coding CSS, and make the
development of a standards-based WYSIWYG editor more difficult than
expected.

This is so very much true. For example, if you want text to flow in 2
columns, basically you have to manually move the the text to the
appropriate block. (as opposed to, for example, text being auto word
wrapped by a specified width when the text is long. See: CSS Text
Wrapping)

Also, although you can make a page's layout using CSS instead of
Tables, but if you want more fine grained layout, such as using nested
tables, CSS pretty much fails. You'd spend several hours trying do it
and come out with unsatisfactory result. (see also: Tableless Layout
with CSS) I'd say, just use tables.

CSS's tag matching scheme (so-called Selectors) is also pretty weak
and ad hoc. For example, there's “:first-child” to match the first
child of a tag, but you can't match second child, third, etc, or last.
“AAA + BBB” will match BBB only if there exist in the same level a
AAA, and comes before it. But, you can not specify a match where there
must be a CCC that comes after.

Generally speaking, html and xml are tree structures. With this
perspective, you can see that css selectors are just a way to match
tree branches. With a tree, you have concepts of root, level/depth,
parent/child/siblings, ordering of siblings. For a tree matcher, in
its full generality, you can consider a scheme where all these tree
properties can be specified. (in a way, similar to pattern matching in
functional languages.) Of course, css isn't a computing language, so,
for designing its Selector, efficiency needs to be considered. In any
case, the way css's seletors is today, is rather ad hoc and very weak.

Also, the selector expression can not use parens to specify
precedence. This is a need i actually had a few times for my own site.
(it'll take some time to write explanation. Will have to add example
here later.)

Two other criticisms from Wikipedia i particularly find to be
important are:

CSS offers no way to select a parent or ancestor of an element
that satisfies certain criteria. A more advanced selector scheme (such
as XPath) would enable more sophisticated style sheets. However, the
major reasons for the CSS Working Group rejecting proposals for parent
selectors are related to browser performance and incremental rendering
issues.

While horizontal placement of elements is generally easy to
control, vertical placement is frequently unintuitive, convoluted, or
impossible. Simple tasks, such as centering an element vertically or
getting a footer to be placed no higher than bottom of viewport,
either require complicated and unintuitive style rules, or simple but
widely unsupported rules.[clarification needed]

Xah
∑ http://xahlee.org/


dorayme
2010-01-28 20:45:44 UTC
Permalink
In article
<5b7d350e-d059-4155-a051-***@g28g2000prb.googlegroups.co
m>,
Post by Xah Lee
Also, although you can make a page's layout using CSS instead of
Tables, but if you want more fine grained layout, such as using nested
tables, CSS pretty much fails.
It sounds odd to say "use CSS instead of tables" - although it is
sort of understandable. The oddness stems from the fact that
tables can be and are often styled by CSS.

"Use CSS instead of CSS!"

"Use tables styled with CSS instead of using other elements
styled with CSS" (getting better...)

Fine-grained layout? That adapts to different platforms,
different browsers, different eyesights? Here is the finest
grained layout strategy for this: semantic mark up with no author
styling at all.
--
dorayme
Kevin Scholl
2010-01-29 15:20:52 UTC
Permalink
    While new additions to CSS3 provide a stronger, more robust layout
feature-set, CSS is still very much rooted as a styling language, not
a layout language. This problem has also meant that creating fluid
layouts is still very much done by hand-coding CSS, and make the
development of a standards-based WYSIWYG editor more difficult than
expected.
There is no such thing as a true WYSIWYG editor. Inefficient and
bloated code generated by such tools is often the root of the problem.
Nothing wrong with hand-coding, fluid layouts or otherwise; in fact, I
and many others would argue that you should be able to hand code, if
for no other reason than so you truly understand what's going on.
Also, although you can make a page's layout using CSS instead of
Tables, but if you want more fine grained layout, such as using nested
tables, CSS pretty much fails. You'd spend several hours trying do it
and come out with unsatisfactory result. (see also: Tableless Layout
with CSS) I'd say, just use tables.
I'd say the develop failed, not CSS. It is possible to create some
pretty complex layouts with CSS, and still keep it cleaner than nested
tables.

[Snip all the selector commentary, as it's been hashed already.]
    While horizontal placement of elements is generally easy to
control, vertical placement is frequently unintuitive, convoluted, or
impossible. Simple tasks, such as centering an element vertically or
getting a footer to be placed no higher than bottom of viewport,
either require complicated and unintuitive style rules, or simple but
widely unsupported rules.
Nah. Practice, practice, practice. It's not THAT hard. Sure, some
hacks are sometimes required (most often to support the various
versions of Internet Exploder ... er, Explorer ... but more often than
not, once you've established a methodology, it can be reused over and
over. For example, the footer issue mentioned (known as a "sticky
footer") has a number of proven solutions.

Loading...