Forum Moderators: phranque
I've already taken a college class that introduced me to Dreamweaver's design mode and the basics of Flash. But the only code I know is what little html I've been able to reverse-engineer by going between the design and code modes in Dreamweaver. A friend who does web development professionally highly recommended that I learn CSS. I've looked into other college classes and found one on CSS, but it rquires a class on XHTML as a prerequisite.
So my first total noob question is this: Can anyone tell me if it is indeed necessary to know XHTML to write CSS? Are there advantages to one over the other? CSS sounds like much less work to type, but is it as versitile/precise?
But, one question. Have you tried taking a look at any online tutorials or even just html/css books? Both approaches would be cheaper than taking a course while still getting you everything you need to know.
Can anyone tell me if it is indeed necessary to know XHTML to write CSS?
Absolutely not. But what you do need to know is how XHTML is different than HTML and what it's used for. Many developers simply use XHTML because they've been told it's the latest and greatest, and is going to replace HTML. In 1999, that was plausible, today, I don't agree that it is.
XHTML was intended to incorporate the features of XML into HTML web pages to allow (among other things) extensible elements/tags to beyond the standard HTML elements. That is, we are familiar with the base HTML set of elements; <body>, <h1>, <p>, and so on. With XHTML, you can create your own DTD (Document Type Definition) that allows you to incorporate your own tags to create a smart document, feeding contextual information to the client. Take, for example,
The Titanic is a movie about a titanic ship that sunk in the Atlantic ocean. The ship's name was Titanic.
In context, a search engine cannot distinguish between the various uses of the word titanic. XHTML, paired with a valid DTD, you can do this,
<moviename>The Titanic,</moviename> is a movie about a <adverb>titanic</adverb> ship that sunk in the Atlantic ocean. The ship's name was <shipname>Titanic</shipname>.
... and in your DTD, define the context described by moviename, adverb, and shipname. You now have a smart document that differentiates context for these three occurrences of the same word.
So what happened? XHTML never really "took off" in original spirit, it never replaced HTML, and all that said it was going to are now facing the HTML 5 draft which tells us HTML will be around for a while . . .
IMO, the proper use of XHTML opened too many doors for spam tactics and was just too much work for developers (paired with a series of horrible browsers that were hard enough to get to play together.) But for whatever reason, the XHTML doctype stuck as the latest and greatest to many, and is still in use . . . even though 95% of the content created from them is plain old . . . HTML.
So unless you plan on using the features that require an XHTML doctype, it's just not proper to (mis)represent your documents as XHTML when in fact, your document (and in most cases, your server) are serving up HTML. Use an HTML doctype.
Choosing the Best Doctype For Your Site [webmasterworld.com]
Why most of us should NOT use XHTML [webmasterworld.com]
For CSS, this is a great kick-start course you can begin using right away:
W3 Schools CSS [w3schools.com]
Although I am a big fan of W3 Schools as a learning resource, IMO the XHTML section they have there is highly inaccurate and sorely outdated. The information above is not even mentioned there, and is summed up by
XHTML is a stricter and cleaner version of HTML.
Which IMO borders on false. You can have strict HTML using a strict doctype, you can have clean HTML with a consistent and valid coding style. A more accurate statement is XHTML incorporates the extensible markup of XML into the HTML markup language to create smarter documents.
So, no . . . if you learn HTML well and validate your documents, you don't really need to understand XHTML. As it's used by most sites today, XHTML is mostly plain HTML anyway.
She said that the "only code I know is what little html I've been able to reverse-engineer by going between the design and code modes in Dreamweaver".
So, I think her question could be reformulated as whether she should learn xhtml (or html) before learning CSS.
Since CSS selectors operate on html/xhtml tags, I think the answer still is that you should be either comfortable with html or xhtml prior to learning CSS or, perhaps more ideally, you could try to learn about the two in tandem.