Forum Moderators: phranque

Message Too Old, No Replies

XHTML & CSS

XHTML & CSS

         

Tenaya

8:14 am on Jan 16, 2009 (gmt 0)

10+ Year Member



Hello. I am new to this forum and new to web design, so I apologize in advance for my ignorance. I began working on a non-business website with another person nine years ago as a hobby without actually knowing anything about the technology involved. I did all the writing, answered most emails, and helped design the layout while my partner handled the code. Ever since she discontinued working on our site a couple years back, I've been on a mission to learn whatever is necessary to maintain the site on my own. However I've found that it is sorely outdated, (made in Netscape Composer with frames for an 800x600 screen resolution) and am now looking to redesign it.

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?

danielcer

10:22 am on Jan 16, 2009 (gmt 0)

10+ Year Member



Yeah. Since html/xhtml and css go hand in hand, you should learn both. It also makes sense to either learn CSS after at least being somewhat comfortable with html or to learn them simultaneously.

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.

rocknbil

2:26 pm on Jan 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard Tenaya!

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.

phranque

4:13 pm on Jan 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



that's a great analysis of the situation!
and fyi rocknbil i already had those two threads flagged and that url bookmarked so i like your thinking.
=8)

danielcer

3:31 am on Jan 17, 2009 (gmt 0)

10+ Year Member



Rocknbil, while that is a detailed analysis of the xhtml vs. html situation, I think the original poster is new to both xhtml, CSS, *and* html.

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.

koan

4:59 am on Jan 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well if you use the XHTML doctype, when it's to validate, you get errors if you forget some quotes inside attributes, use upper case tags or forget to close them, etc, so yeah, in a way, it forces you to write clean HTML and learn the right way.

Tenaya

10:12 am on Jan 22, 2009 (gmt 0)

10+ Year Member



Thank you all very much. I still have a lot to learn, but at least this helps to give me some idea of where to start.