473,442 Members | 4,700 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why is CSS not XML?

Hi,

I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical? (Maybe
no namespaces back then or something like that?)
-- Holger
Jul 20 '05 #1
13 4097


peters wrote:

I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical? (Maybe
no namespaces back then or something like that?)


Not everyone was infected with tagitis when CSS was designed :). But
even now languages like XQuery are designed which are no XML
applications (although I think for XQuery there is an alternative XML
syntax).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
peters <pe****@holger-peters.de> writes:
I'm using CSS, HTML and XML for some time. I've always asked myself
why CSS is not an XML format. What are the reasons? Is it historical?
(Maybe no namespaces back then or something like that?)


What would be gained from making it XML-based? A reduction in
human-readability, and I would imagine a far worse selector syntax.

<rule element="div">...</rule> for div {...} isn't *too* bad.

How would one sensibly and readably write
body.corporate > #navigation .selected:first-letter { ... }
in XML, though?

Okay, <rule selector="body.corporate ..."> - but what's the advantage?

--
Chris
Jul 20 '05 #3
On Tue, 21 Sep 2004 16:59:47 +0000, peters <pe****@holger-peters.de> wrote:
Hi,

I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical? (Maybe
no namespaces back then or something like that?)


XML is a markup language. CSS is not designed to be a markup language,
it's instead used to provide optional styling for selectors which refer to
a specific or general markup element. So I don't see how a markup version
of CSS would be useful.
Jul 20 '05 #4
*Neal* wrote in comp.infosystems.www.authoring.stylesheets:
*peters* wrote:
I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical? (Maybe
no namespaces back then or something like that?)


XML is a markup language. CSS is not designed to be a markup language,
it's instead used to provide optional styling for selectors which refer to
a specific or general markup element. So I don't see how a markup version
of CSS would be useful.


Best not mention XSLT then :-)
--
Andrew Urquhart
- CSS FAQ: http://www.css.nu/faq/ciwas-aFAQ.html
- Archive: http://andrewu.co.uk/r/?4 (Google Groups)
- Contact me: http://andrewu.co.uk/contact/
Jul 20 '05 #5

"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Tue, 21 Sep 2004 16:59:47 +0000, peters <pe****@holger-peters.de> wrote:
Hi,

I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical? (Maybe
no namespaces back then or something like that?)


XML is a markup language. CSS is not designed to be a markup language,
it's instead used to provide optional styling for selectors which refer to
a specific or general markup element. So I don't see how a markup version
of CSS would be useful.


You're conflating the markup language itself with its applications. XML is a
method of marking up data. Style information is data to which XML can be
readily applied, and hierarchies in the language to which the styles are
being applied can be reflected.

<hook rel="top" type="tag" name="div">
<hook rel="same" type="id" name="navbar">
<property name="background-color" value="#cff" />
<property name="color" value="black" />
<property name="margin" value="1em" />
<hook rel="first-letter" type="pseudo">
<property name="float" value="left" />
<property name="font-size" value="300%" />
</hook>
<hook rel="descendent" type="tag" name="h3">
<property name="font-weight" value="bold" />
<property name="color" value="#880" />
</hook>
</hook>
</hook>

This corresponds to:

div#navbar {
background-color: #cff;
color: black;
margin: 1em;
}

div#navbar:first-letter {
float: left; font-size: 300%;
}

div#navbar h3 {
font-weight: bold;
color: #880;
}

Having said that, I think CSS is easier to read and write!

Jul 20 '05 #6
On Tue, 21 Sep 2004 12:40:54 -0400, Harlan Messinger
<h.*********@comcast.net> wrote:
You're conflating the markup language itself with its applications. XML
is a
method of marking up data. Style information is data to which XML can be
readily applied, and hierarchies in the language to which the styles are
being applied can be reflected.
Admittedly, I'm not knowledgeable about XML in the specific. I'm aware
there are styling conventions unique to it, but am not yet ready to fully
understand them!
... I think CSS is easier to read and write!


Agreed. For use in a WWW environment, CSS is a better method, it would
certainly seem.
Jul 20 '05 #7
Chris Morris <c.********@durham.ac.uk> wrote:
peters <pe****@holger-peters.de> writes:
I'm using CSS, HTML and XML for some time. I've always asked myself
why CSS is not an XML format. What are the reasons? Is it historical?
(Maybe no namespaces back then or something like that?)
What would be gained from making it XML-based?


Lots of kewlness!!! And eXtensibility, and Structure, and, and, ...
A reduction in human-readability,
Yeah, that's what SGML was designed for, and XML made a big improvement.
and I would imagine a far worse selector syntax.
Maybe worse, but maybe not _far_ worse. CSS selector syntax is already
tricky; it's far too easy cause a real mess by forgetting a "." or
by misplacing a space.
<rule element="div">...</rule> for div {...} isn't *too* bad.
It could also be
<div>...</div>
How would one sensibly and readably write
body.corporate > #navigation .selected:first-letter { ... }
in XML, though?

Okay, <rule selector="body.corporate ...">
<body class="corporate"><any id="navigation" rel="child">
<first-letter><any class="selected">...</any></first-letter></any></body>

And if ... is, say, font-size: 16pt, then it could be
<font size="16pt"/>
or, more XML'ically,
<font size="16" unit="pt"/>

But I'm happy they didn't invent it. This leaves room for XHTML 3.0,
which makes things much simpler! ( http://w2c.shorturl.com )
- but what's the advantage?


Basically the same as the advantage of XHTML.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #8
On Tue, 21 Sep 2004 16:59:47 +0000, peters <pe****@holger-peters.de>
wrote:
I'm using CSS, HTML and XML for some time. I've always asked myself why
CSS is not an XML format. What are the reasons? Is it historical?


Well, the exact answer to that may not be so easy to find but one very
simple reason may be that the work on what would eventually become XML
had just barely started when CSS1 got close to its final state in 1996.

A couple of other points of interest can be found in the book "Cascading
Style Sheets - Designing for the web" by Håkon Vium Lie and Bert Bos,
first published in 1997.

There we can quote the following, in the foreword by Robert Cailliau at
CERN...

"I followed the CSS effort from its inception - mostly over cups
of coffee with Håkon at CERN - and I've always had one concern:
is it possible to create a powerful enough style sheet language
without ending up with a programming language?"

....and in the preface of the same book, from Håkon and Bert...

"CSS uses common desktop publishing terminology that you probably
know from before"

That last quote seems to indicate that the CSS syntax was chosen to
allow for an easy adoption by a web community that was already "in deep
shit" by its use of HTML as a command language to tweak www pages into
display (as encouraged by Mosaic, and later Netscape, of that time),
instead of using it as the syntactic markup language it was originally
designed to be (well, there's some limits to that as a truth too, but
let's not get picky :-).

It's not like the world did not already have a styling language
available at the time. DSSSL[1] was already defined, as a full sized
style and transformation language for applications of SGML.
There where other styling languages in use too at the time, for
applications of SGML, and you can find links to info on some of them in
the m-FAQ for this NG.

Now we are close to 8 years later, from where CSS1 first became a
recommendation and during that time XML, and a few applications of it,
have matured into a usable state.

Most especially, when the XSL project once started it was soon found
that a styling language written in XML was of limited use for the
emerging XML community, except for one of the modules that came out of
the original XSL project.

XSL-T (T for transformation) came to be the same for applications of XML
as DSSSL already was for applications of SGML.

XSL-T shares the characteristics of DSSSL in the sense that even XSL-T
is a fully Turing Complete programming language, but it also shares
another part with DSSSL, the learning curve is steep for the average www
author.

So; CSS is what it is because it is meant to be simple for all to learn
and understand with less effort, as compared to another definition
approach.

So far CSS standard developments has also withstood all attempts to let
CSS be converted into a programming language (i.e. to have procedural
constructs included in the syntax).

The lack of such constructs in CSS is what makes it safe and secure for
www use, as compared to an implemented scripting language interpreter in
a UA, that allows for execution of an externally picked up "program"
directly in a users browsing environment.

In all honesty though; the absolute majority of scripts that are in
circulation on the www today are there to be annoying, but not really
designed to destructive, to a user.

But naturally we do have one "sinner" who could not hold back on an
attempt of their own in the "CSS with procedures" area.
MS-IE[3] supports (with bugs of course) something that goes by the name
of BECSS[2].

[1] DSSSL - Document Style Semantics and Specification Language.
A fully Turing complete programming language that in it self is
defined as an application of SGML; i.e. a DSSSL program is governed
by its own DTD and can be validated just like any other piece of
SGML based markup.
DSSSL can be used to style and transform valid instances of HTML
too, but at the cost of a very steep learning curve.

[2] BECSS - BEhavioral Cascading Style Sheets
Read all about it, here ... and then forget about it...
<http://www.w3.org/TR/1999/WD-becss-19990804>
...also read any and all threads of comments on lists.
This may be as good start as any...
<http://lists.w3.org/Archives/Public/www-style/1999Sep/0112.html>

[3] MS-IE - MicroSoft Internet Explorer
As per MS claims, a very important component of the MS-Windows
operating system. A fact that came as a shock to MS to when
they internally discovered that it was too much true.
Make no mistake here now. In order to keep a latest version of
MS-IE running for free on old systems, they had to include so
many updates to those old op-systems that it started to be a
threat to the real source of revenue for MS, namely the sale of
new operating systems.
Hence, the quality updates of MS-IE was stopped some years back
and from that time only security related updates has been allowed.

--
Rex
Jul 20 '05 #9
In article <2r*************@uni-berlin.de>,
"Harlan Messinger" <h.*********@comcast.net> wrote:
<hook rel="top" type="tag" name="div">
<hook rel="same" type="id" name="navbar">
<property name="background-color" value="#cff" />
<property name="color" value="black" />
<property name="margin" value="1em" />
<hook rel="first-letter" type="pseudo">
<property name="float" value="left" />
<property name="font-size" value="300%" />
</hook>
<hook rel="descendent" type="tag" name="h3">
<property name="font-weight" value="bold" />
<property name="color" value="#880" />
</hook>
</hook>
</hook>

This corresponds to:

div#navbar {
background-color: #cff;
color: black;
margin: 1em;
}

div#navbar:first-letter {
float: left; font-size: 300%;
}

div#navbar h3 {
font-weight: bold;
color: #880;
}


That's one of the best arguments I've ever seen for why CSS syntax is
much preferable to an XML-based style language, and why I'll never be
interested in a reformulation of CSS as XML.
Most of the other great arguments against XMLifying CSS were the
examples I've seen of XSL:FO, as it happens.

--
Eric A. Meyer - http://www.meyerweb.com/eric/
Jul 20 '05 #10
Harlan Messinger <h.*********@comcast.net>:

<hook rel="top" type="tag" name="div">
<hook rel="same" type="id" name="navbar">
<property name="background-color" value="#cff" />
<property name="color" value="black" />
<property name="margin" value="1em" />
<hook rel="first-letter" type="pseudo">
<property name="float" value="left" />
<property name="font-size" value="300%" />
</hook>
<hook rel="descendent" type="tag" name="h3">
<property name="font-weight" value="bold" />
<property name="color" value="#880" />
</hook>
</hook>
</hook>
That's of course over the top, I would have made it (if I had to) rather
something like this:

<rule selector="div#navbar">
<background><color>#cff</color></background>
<color>black</color>
<margin>1em</margin>
</rule>
<rule selector="div#navbar:first-letter">
<float>left</float>
<font><size>300%</size></font>
</rule>
<rule selector="div#navbar h3">
<font><weight>bold</weight></font>
<color>#880</color>
</rule>

or (because I know, that it's easier to access attribute value than
element contents)

<rule selector="div#navbar">
<background color="#cff"/>
<text color="black"/>
<margin top="1em" right="1em" bottom="1em" left="1em"/>
</rule>
<rule selector="div#navbar:first-letter">
<flow float="left"/>
<font size="300%"/>
</rule>
<rule selector="div#navbar h3">
<font weight="bold"/>
<text color="#880"/>
</rule>

Some people would propably prefer XPath over CSS selectors, which are
neither split into several attributes.

Sadly, "</>" isn't allowed in XML, although, if the only shorttag feature
used, there would---thanks to mandatory wellformedness---be no
ambiguities, but a lot of code reduction and readability gain.
Having said that, I think CSS is easier to read and write!


Sure, it's made with that in mind, at least up to level 2.1. The only
advantage of an XMLish CSS would have been one parser (and maybe some
bugs) less.

--
"See... *That* is the problem... Scotch is for sipping, relaxing, and deep
thoughts... Jack is what you drink when you need to work through the pain."
John C. Welch
Jul 20 '05 #11
Christoph Paeper wrote:
That's of course over the top, I would have made it (if I had to) rather
something like this:

<rule selector="div#navbar">


So you have to parse the XML to extract the selector, then you have to run
the selector through an entirely different parse engine to extract any data
from it.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #12
David Dorward <do*****@yahoo.com>:
Christoph Paeper wrote:
<rule selector="div#navbar">


So you have to parse the XML to extract the selector, then you have to
run the selector through an entirely different parse engine to extract
any data from it.


Yes, but where is the difference to XML+XPath or CSS?
Even with pure XML, like

<rule elementtype="div" id="navbar">

you have instance access to the parts of the selector, but you still have
to map it onto a DOM.

Nevertheless, I do not want to reformulate CSS in XML, I just wanted to
show, that it did not have to look /that/ ridiculous. I think a different,
rather opposite thing is more interesting: the description of an XML
application in CSS syntax, i.e. yet another DTD, Schema, ... replacement.

--
"I have opinions of my own -- strong opinions --
but I don't always agree with them." - George Bush
Jul 20 '05 #13
Jan Roland Eriksson said the following on 22/09/2004 00:06:

[snipped a very interesting story]
[2] BECSS - BEhavioral Cascading Style Sheets
Read all about it, here ... and then forget about it...
<http://www.w3.org/TR/1999/WD-becss-19990804>


Well, I'm not that much of a M$ fan, so I was willing to forget about it
before reading, but I had a quick glance at it and then realised that a
trick I learned from Eric Meyer's book "More Eric Meyer on CSS" uses
BECSS. The trick uses an .htc file from Peter Nederhof, who has a page
about it at:

http://www.xs4all.nl/~peterned/csshover.html

One thing which isn't mentioned on that page is that bahaviour makes a
stylesheet invalid (Eric's book does mention it).

--
Regards
Harrie
Jul 20 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.