Click to See Complete Forum and Search --> : Is the language for CSS, XHTML ?


smoker
05-22-2005, 03:44 AM
HI,

Please excuse my ignorance.

I am just starting to look into css and have one basic confusion, is the language used for css, xhtml, or is the latter something completely different ?

Thanks for help.

Ray

the tree
05-22-2005, 04:09 AM
CSS styles XML, HTML, XHTML, mathML and could hypothetically style RSS although there'd be little point. If your happy with HTML, then use HTML and CSS, but if you want to delve into XHTML, then feel free.

Charles
05-22-2005, 05:05 AM
but if you want to delve into XHTML, then feel free.But be aware, XHTML is very different from HTML. Do not use it unless you have read http://www.w3.org/TR/xhtml1/#guidelines .

drhowarddrfine
05-22-2005, 07:36 AM
Do you really think xhtml is "very" different from html? I consider it the same with a few tweaks here and there. Since xhtml, and eventually xml, are the near future, I'd go with xhtml.

CSS is really a description more than a language. And (x)html is not CSS. (x)html describes the page content while CSS describes its appearance/presentation.

While they are two different things, it comes in handy because you can describe your pages contents with html and later describe, or change, its appearance with css.

Charles
05-22-2005, 07:50 AM
Do you really think xhtml is "very" different from html? I consider it the same with a few tweaks here and there. Since xhtml, and eventually xml, are the near future, I'd go with xhtml.Apparently you don't understand XHTML. If you aren't going to read the XHTML 1.0 spec. at least read the HTML Compatability Guidelines where it details some of the ways that the two differ.

XHTML isn't "the near future" it's something different than HTML. For general use on the web HTML is and will remain the standard. But for special use, when mathematicians want to extend MathML they will need to combine it with XHTML.

felgall
05-22-2005, 03:50 PM
XHTML 1.1 is the latest HTML standard from W3C.

HTML 4.01 is now two versions behind that standard and was the last HTML version to ever be produced. Provided that you code your pages correctly XHTML 1.0 transitional will produce usable web pages even in old browsers such as Netscape 4. You just need to be more careful and consistent with your coding when using XHTML. Properly coded HTML is not really much different but browsers are more forgiving of errors in HTML.

smoker
05-22-2005, 04:05 PM
Hi Felgall,

But how do I find out the differences between html and xhtml? I can do html but I need to know what I have to change to make it xhtml ??

It's simply a question of information and where do I find it?

Thanks a lot.

Ray

drhowarddrfine
05-22-2005, 06:04 PM
As this link (http://www.w3schools.com/xhtml/xhtml_html.asp) will say, "XHTML is not very different from HTML 4.01"

You could also look at the W3C (http://www.w3.org/TR/xhtml1/#guidelines).

Many of the books at the library on xhtml will talk about how to convert from html to xhtml and their differences.

Jeff Mott
05-22-2005, 09:28 PM
As this link will say, "XHTML is not very different from HTML 4.01"The W3Schools also say that "HTML was designed to display data", which is not true. W3Schools is not a real authority in Web technologies. It is merely someone's pet project that just happens to have become popular. And while much of the site can certainly be useful to beginners, it is not a difinitive source.

That being said, I agree that the W3C means for XHTML to replace HTML. The W3C does say that "XHTML is the successor of HTML". For another example, the path to the most recent HTML specification <http://www.w3.org/TR/html/> in fact takes you to the XHTML spec.

Also, Charles, how is it that you consider XHTML to be very different? Many of the differences were recommendations from HTML made into rules for XHTML. The biggest difference is the move to XML, which is the only difference that justified these differences from simply becoming HTML 5.

The way the XHTML spec was written also implies that the two are very similar. That is, the XHTML spec is not a full language definition. It is a list of differences from HTML then refers the reader back to the HTML spec. Could VBScript refer the reader back to the definition of JavaScript and then only list the differences? No. Because that is what it really means for two languages to be very different. HTML and XHTML are relatively very similar.

Charles
05-23-2005, 04:08 PM
Newer doesn't mean "better" or even "for the same thing". With HTML 4.01 HTML has achieved a state of perfection. HTML is for documents published on the web for general public use. XHTML is about something different. And if you think that XHTML is simply HTML with stricter rules, that XHTML is a subset of HTML then you are wrong.

Consider the following XHTML 1.0 document:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [
<!ENTITY hello-world '<h4>Hello, World!</h4>'>
]>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello</title>
</head>
<body>
&hello-world;
</body>
</html>That's a well formed and completely valid XHTML document that will not work on an HTML browser. Nor will it work on any browser that thinks that it is HTML. Save it with a ".html" extension and try it out. Now save it with a ".xml" extension to tell the browser that it is XHTML. Sadly, you'll have to use MSIE because it's the only browser that currently handles this stuff properly.

You'll note that the document suddenly works, but it doesn't give us something useful to a human. Add a line to that document:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [
<!ENTITY hello-world '<h4>Hello, World!</h4>'>
]>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello</title>
</head>
<body>
&hello-world;
</body>
</html>And then save the following to the same folder and with the name "test.xsl":
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
encoding="iso-8859-1"
indent="yes"
method="html"
version="4.01"/>

<xsl:template match="*|@*" >
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>Now display the altered first document in MSIE and you'll see that it works. What we've done is attached to the document a style sheet that describes how our document should be CONVERTED TO HTML.

And we can demonstrate the difference going the other direction:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello</title>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<h4>Hello, World!<\/h4>');
// -->
</script>
</body>
</html>

That is again well formed and valid but it will not run as desired in XHTML. Save it with a ".html" extension and magically it works.

There are three ways to use XHTML.

1.We can really use the thing with all of its special features, perhaps combining it with MathML, perhaps using XSLT to fill out the template.
2.We can write documents that are a hybrid of HTML and XHTML, serving them to browsers as HTML but following all of the rules of both languages.
3.We can take our HTML documents, add quotes around all attribute values, change to lower case all attribute and element and names, include all optional tags and add the trailing slash to the empty tags.

If you are really using 1, then go ahead. Chances are you are using the right tool for the job. If you're using 2, then I have to ask why? You've gained nothing except that headache of making sure that you have followed both sets of rules. And I know very few who follow both sets of rules. You certainly wont be doing so if you follow that article from the W3 Schools. And I have grown weary of trying to get people to stop commenting out their scripts in XHTML. If you are following 3, well then you are just producing what I call, for lack of a better term, "crap". You have something that is neither HTML nor XHTML. And why? Simply to look cool?

drhowarddrfine
05-23-2005, 05:01 PM
Worked fine for me in IE6 and Firefox.

You're header is invalid though. Remove the entity statement. Valid DTD (http://www.w3.org/QA/2002/04/valid-dtd-list.html)

In fact, the whole thing still doesn't validate.

I think you are mixing too much xml in when he's just trying to get to xhtml and xhtml is pretty close to regular html.

Charles
05-23-2005, 05:17 PM
XHTML is, by definition, an XML application see http://www.w3.org/TR/2004/REC-xml-20040204/ .

I just ran my example through The Validator (http://validator.w3.org) and everything is well formed and valid. As I stated above, you don't know what XHTML is.

drhowarddrfine
05-23-2005, 05:40 PM
Hm. I guess I did it wrong the first time because I can validate it also.

In any case, I know what you are speaking of in regards to presenting xhtml as html and there is a difference. However, this difference is not important to the original poster at this time since he is only trying to learn how to do it and what those differences are. The differences, as you present them, is beyond his "scope", if you will, at this time.

In this case writing xhtml is very similar to html and you can learn the differences as you go along. The idea, Charles, is to be helpful to the learner and not put up walls while insulting others.

Charles
05-23-2005, 06:43 PM
Hm. I guess I did it wrong the first time because I can validate it also.

In any case, I know what you are speaking of in regards to presenting xhtml as html and there is a difference. However, this difference is not important to the original poster at this time since he is only trying to learn how to do it and what those differences are. The differences, as you present them, is beyond his "scope", if you will, at this time.

In this case writing xhtml is very similar to html and you can learn the differences as you go along. The idea, Charles, is to be helpful to the learner and not put up walls while insulting others.Our purpose here is spreading the truth and fighting ignorance. If your ego got in the way then I'm sorry about that. Go see Return of the Sith for a cautionary tale about such attachments.

Using real XHTML for its intended purpose is well and good but I rarely see it here. Perhaps those folks have little need for our help.

The XHTML/HTML hybrid is well but pointless. No doubt this is what many think that they are using, but I've seen only a few that achieve this.

What I call "crap" is, well, crap. As a rule one doesn't go from "crap" to XHTML/HTML hybrid, one must first grasp the essence of real XHTML and then one can proceed to the hybrid. I suppose one could start with "crap" and then come to understand real XHTML and then proceed to the hybrid. If that is the case then it is doubly important that people know when they are dishing out "crap" and doubly important that they know where their next step to enlightenment lies.

drhowarddrfine
05-23-2005, 10:26 PM
Well, then, thank you for giving us an example of crap. You do so very well.

DaveSW
05-24-2005, 06:55 AM
If you wish to continue this debate, kindly do so without degenerating into a slanging match.

The XHTML/HTML hybrid is well but pointless. No doubt this is what many think that they are using, but I've seen only a few that achieve this.

Charles, whilst I can agree that html 4.01 works better, how come the W3C is using XHTML 1.0 Strict for their homepage?

MstrBob
05-24-2005, 10:44 AM
From reading the specs and announcements I get the distinct impression that they are moving to replace HTML with XHTML. Now, this is probably a ways off, as major browsers still don't support XML, let a lone XHTML, properly. One can easily see the benefits of using XHTML, and the fact that the W3C would be able to release new XHTML versions and XML browsers would be able to handle it without a rewrite.

Now of course the W3C is going to use XHTML 1.0, it's there new technology, they have to be cutting edge. The point of the XHTML/HTML hybrid is to get pages already in the XML-like syntax, so in the future it's much easier to make your webpages proper XHTML. Think of it as future-proofing your pages, in a way. With this method, however, you lose the benefits of XHTML as it's all being parsed as HTML.

I prefer to use content negotiation. Based on the HTTP headers sent by a browser, if it says it supports and prefers XHTML, then I'll send it an XHTML document. If it says it doesn't support HTML, prefers HTML, or doesn't send the HTTP header, I'll send it an HTML 4.01 document. (At the moment my own private website doesn't send HTML, but I didn't do that backend.) I think this, or more simply just using HTML 4.01 makes the most sense for the web right now.

We're not on a web right now that is entirely capable of handling XHTML. As such, HTML 4.01 is a perfectly acceptable, if not better markup language. Hopefully, in the years to come, that'll change.

Charles
05-24-2005, 03:09 PM
I prefer to use content negotiation. Based on the HTTP headers sent by a browser, if it says it supports and prefers XHTML, then I'll send it an XHTML document. If it says it doesn't support HTML, prefers HTML, or doesn't send the HTTP header, I'll send it an HTML 4.01 document. (At the moment my own private website doesn't send HTML, but I didn't do that backend.) I think this, or more simply just using HTML 4.01 makes the most sense for the web right now. And the easy way to keep those two versions synchronized is with XSLT. And you can have any number of different versions of any page served according to the user's capability. But you will have to use real XHTML and not "crap". It's really "crap" that I have trouble with and not XHTML itself. That and that so many people are producing "crap" all the while insisting that it is XHTML.

Jeff Mott
05-24-2005, 07:04 PM
That's a well formed and completely valid XHTML document that will not work on an HTML browserWell, yeah. I wouldn't expect a perl5 script to run on a perl4 interpreter either. That doesn't mean that perl5 is very different from perl4, as you claim about XHTML and HTML.

There is no doubt that there are plenty of new and useful things we can do with XHTML that was not possible with HTML. I would agree that these new features are very different from HTML. But XHTML is bigger than just those new features. It does still include the basic document structure, such as the head and body, paragraphs, lists, tables, links, objects, frames, forms, etc. It is all of XHTML that makes it still very similar to HTML. Right in the DTD for XHTML strict: "This is the same as HTML 4 Strict except for changes due to the differences between XML and SGML." So all I am saying is that while there are differences, the whole of each language is not nearly as different as you make it out to be.

We can take our HTML documents, add quotes around all attribute values, change to lower case all attribute and element and names, include all optional tags and add the trailing slash to the empty tags ... you are just producing what I call, for lack of a better term, "crap". You have something that is neither HTML nor XHTMLJust because you don't happen to use XHTML to it's fullest potential means that it is not really XHTML? And just because you fail to make use of one of many of the benefits means it is crap? Because there are still benefits of what you call crap over normal HTML. Those benefits are listed explicitly in the XHTML spec.