htm or html

B

bender

A newbie question,
Is there any difference between .htm and .html ? I mean, does the webserver
or browser treat the two file formats any differently ? Is one of them
preferred over the other ?
 
M

Matthias Gutfeldt

bender said:
A newbie question,
Is there any difference between .htm and .html ?

Apart from the "l", no.

I mean, does the webserver or browser treat the two file formats any differently ?

Webservers are usually configured to send both .htm and .html files as
text/html, so usually there shouldn't be any difference.

Browsers usually treat both .html and .htm files as HTML.

Is one of them preferred over the other ?

Yeah, .html makes more sense than .htm


Matthias
 
B

bender

Matthias Gutfeldt said:
Apart from the "l", no.

differently ?

Webservers are usually configured to send both .htm and .html files as
text/html, so usually there shouldn't be any difference.

Browsers usually treat both .html and .htm files as HTML.



Yeah, .html makes more sense than .htm


Matthias

Just like I thought then, thanks for your prompt reply :)
 
D

David Dorward

bender said:
Is there any difference between .htm and .html ?

The former is designed for Pre-1995 Microsoft systems.
I mean, does the
webserver or browser treat the two file formats any differently ?

That depends on the server. Usually not, but I've got mine rigged to send
..htm files as HTML, and .html files as XHTML or HTML depending on browser
capabilities. (Its not nice to try to put a HTML 4.01 Strict document that
isn't well formed through an XML parser)
Is one of them preferred over the other ?

..html is more common, so you are less likely to get people making typos if
you use that.
 
M

Micah Cowan

bender said:
A newbie question,
Is there any difference between .htm and .html ? I mean, does the webserver
or browser treat the two file formats any differently ? Is one of them
preferred over the other ?

Well, the browser will treat the file format (when served over
the 'Net) as text/html if that's what the server says it is,
regardless of the filename extension. The file extension should
only matter when it's being read from disk (and thus doesn't come
with a Content-Type header). In this case, the browsers I've used
are usually smart enough to change/tack-on the extension to
'html' (or something) so that it will be able to understand that
it's an HTML document when it reads it back again some other
time.

Between the two, I prefer .html, since .htm only ever really
existed for systems which limit extensions to 3 characters.

-Micah
 
E

e n | c k m a

That depends on the server. Usually not, but I've got mine rigged to send
.html files as XHTML or HTML depending on browser capabilities.

What's the difference between sending it as XHTML and sending it as HTML?
Is it recommended? Wouldn't the DOCTYPE take care of things like that
anyway?

If it's a recommended practice, how would you set that up on an Apache
server?

Thanks,
Nick.
 
D

David Dorward

e said:
What's the difference between sending it as XHTML and sending it as HTML?

The content type. HTML is sent as text/html, XHTML is sent as text/xhtml+xml
Is it recommended?

What's recommended is sticking to HTML 4.01 until browsers catch up. This is
a personal site so it doesn't matter if it falls over in one or two places.
(Not that I've ever seen it fall over since I sniff, but sending XHTML as
HTML is still (IMO) a hack)
Wouldn't the DOCTYPE take care of things like that anyway?

No. The decision to use an SGML or XML parser takes place before the client
looks at the document.
If it's a recommended practice, how would you set that up on an Apache
server?

http://www.greytower.net/en/archive/articles/xhtmlcontent.html
 
T

Toby A Inkster

e said:
What's the difference between sending it as XHTML and sending it as HTML?
Is it recommended? Wouldn't the DOCTYPE take care of things like that
anyway?

The DOCTYPE *should* take care of it, but browsers ignore the DOCTYPE
except for quirks mode/standards mode switching.
If it's a recommended practice, how would you set that up on an Apache
server?

Something like:

AddType application/xhtml+xml .xhtml .xhtm .xht

But be aware that Internet Explorer and some other older browsers can't
handle the application/xhtml+xml MIME type, so better to use some kind of
Accept-header sniffing rather than blindly serving up the proper MIME
type.
 
T

Toby A Inkster

David said:
XHTML is sent as text/xhtml+xml

How's the weather in your little imaginary world. ;-)

This advice is broken. It recommends:

| RewriteEngine On
| RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
| RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml\s*;\s*q=0
| RewriteCond %{REQUEST_URI} \.html$
| RewriteCond %{THE_REQUEST} HTTP/1\.1
| RewriteRule .* - "[T=application/xhtml+xml; charset=ISO-8859-1]"

But this rule has a loop-hole. Any browser sending:

Accept: foo, bar, application/xhtml+xml;q=0.9, baz, bat

Will not get sent application/xhtml+xml -- they'll get sent text/html
(even if they didn't specify text/html in the Accept line!)

Better to remove line 3 entirely, as no browser send q=0 (as in *really*
0, not 0 point something) anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top