designer wrote:
Just over a year ago, I decided to improve my knowledge of CSS, which
(although I'd been using it for a few years) seemed a good idea.
Yes, that is a very good idea.
I joined the CSS list, then this one, I read Jeffrey Zeldman (and a lot of
web sites about standards) and everything was rosy in the garden. Of
course, I had to overcome the obstacle of thinking in terms of
content/presentation and doing away with tables etc, but once I'd got
through the trauma of floats etc it all made sense. I imagine that's
much the same for all of us.
Yes, we all face those obstacles to begin with and you've done well to
get this far already.
However, just lately (a few months maybe) there has been an increasing
number of folk arguing about xhtml and xml and mime types and oh dear
dear, headaches all around. The result? I now feel totally confused
Confusion amongst beginners about all of these issues is one of the
primary reasons why XHTML is not suitable for beginners, because an
understanding of them is required to be learnt by anyone attempting to
use XHTML.
However, the biggest problem is not that XHTML is complicated, anyone
can learn it if they put in the effort, it's that those of teaching the
beginners are not united on the issue. With different information
coming at you from all different sides, there is no wonder you are
confused by it all.
(I admit I don't really understand all that mime stuff - yet) but more
importantly, my confidence has gone.
It's important that you don't lose your confidence, as I said you've
done extremely well to get where you are and you should be proud of
yourself and your efforts.
By far, the most important issue facing beginners with regards to
standards is the separation of semantics, presentation and behavioural
layers into well structured, valid, non-presentational markup; CSS and
javascript, respectively, and it sounds like you've already made
significant steps toward these goals already.
The other major issue involved, and the one we have been discussing that
has resulted your confusion and lack of confidence, relates to in-depth
technical issues of the medium. MIME types are perhaps one of the most
confusing, as they don't seem to directly relate to how you perceive the
way the web or your development tools work. I will briefly discuss them
for you at the end of this e-mail.
Since Zeldman (and lots of others) told me it was a good idea to write
xhml strict I've done exactly that
In theory, authoring in XHTML does have significant benefits over HTML.
However, the information often left out by those advocating its use by
beginners can have significant consequences (many of which have been
discussed in recent threads). Authoring XHTML requires it be developed
in an XML environment and at least tested extensively under XML
conditions (even if it will eventually be served to the world as HTML).
The fact is that precisely none of the purported benefits of XHTML are
sustained in a purely HTML authoring environment, and that is precisely
how the vast majority of beginners, including yourself, actually end up
developing XHTML, simply because a) information is left out and b) as
evidenced by your e-mail today, beginners cannot be expected to
understand it all anyway.
every site I've done in the last year has been done in xhtml strict. I
did it because people were telling me that it was a good thing, so that
what I've done was easily portable later on. So have I done a daft
thing? I really don't know!
Firstly, to be clear, I do believe XHTML is a very good thing and there
are significant benefits to using it. So, people telling you to use
XHTML is not necessarily a bad thing, but the problem is that you were
not ready for it at the time. Given your current experience, however,
you may now be ready to start learning it all.
I don't think you have done a daft thing, we all need to learn some how.
Whether or you not learned in the most ideal way can be, and is being,
questioned; but regardless of the answer you've still learned very
valuable lessons with regards to standards based development, and as I
said, that is the most important thing.
MIME Types
As I promised, this is a (not so) brief discussion of MIME types and how
they relate to this discussion of HTML vs. XHTML.
Mime types are the means by which applications should determine how to
handle the content they receive from the web. Despite popular
misconceptions (and the behaviour of some broken web browsers in some
cases), file extensions are not supposed to used by the browser to
determine what to do with the file, file extensions are supposed to be
meaningless in the context of the web.
This may seem confusing at first because when you write an HTML file,
you give it a .htm or .html extension and that seems to be how it knows
what type of file it is. In many ways, this is indeed the case, but
there is a necessary step in between that is not quite so obvious.
Common file extensions are typically associated with specific MIME
types. For example:
.htm .html text/html
.xht .xhtml application/xhtml+xml
.gif image/gif
.jpg .jpeg image/jpeg
.png image/png
.txt text/plain
.pdf application/pdf
etc.
So, although the file extension is commonly used for determining the
MIME type, it is the MIME type that the browser should use to determine
what the file is and thus what to do with the it.
When the web server receives a request for a file, it needs to determine
what type of file it is and, thus, what it should tell the browser when
it sends the file. It is common for web servers to make use of the file
extension to determine how to process the file. This is how it knows to
execute .php, .asp or .jsp files, for example, and also how to serve
.html, .png, .jpg, etc. But, for the browser receiving the file over
the web (usually via HTTP), the file extension is meaningless and can be
left off the URI completely.
This information is sent to browser (preferably including character
encoding information for text/* documents) using the Content-Type HTTP
header, and should look something like this for HTML:
Content-Type: text/html; charset=UTF-8
Unfortunately, charset information is generally left out of the HTTP
headers and so for most sites, it will simply be:
Content-Type: text/html
That may look somewhat familiar to you, if you ever used this meta
element in your document:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
In HTML only, the meta element is an inferior attempt at providing this
information within the document itself, but it is not a proper
substitute for real HTTP headers, the HTTP headers always take
precedence. For XML, that particular meta element is not used by the
browser at all, under any circumstances.
As mentioned previously, XHTML really should be served with an XML MIME
type, such as application/xhtml+xml. Technically, any XML mime type
should work if both it and namespace are known to the web browser, but
that is the preferred MIME type to use.
When you use text/html, HTML parsing and rendering rules are applied.
Regardless of any XHTML DOCTYPE you use, XML rules are not applied,
well-formedness errors are handled like any other erroneous HTML
document, the DOM will be generated and worked with, and CSS will be
applied according to HTML rules.
When you use an XML MIME type, XML parsing and rendering rules are
applied. This means that XML well-formedness errors will be fatal and
the user will typically see the "Yellow Screen of Death" (in Mozilla
based browsers), the DOM will be generated and worked with, and CSS will
be applied according to XML rules. This means that any scripts or
styles written and tested under HTML conditions may not function as
expected in XML conditions.
As I mentioned earlier, the MIME type is used by the browser to
determine what to do with the file. Because IE is not aware of what
application/xhtml+xml means, it doesn't recognise it as an XML document
and asks the user what to do with it (either save it or open with
another application).
--
Lachlan Hunt
http://lachy.id.au/
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************