SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Jul 9, 2008, 19:10 #1
serving a document in different mime types?
I'm trying to learn about serving a page as text/html or application/xhtml+xml.... Where is this distinction made? On a server setting? In the meta element's content attribute?
I'm not even sure I'm using the right terminology here..
I really don't understand this aspect of mark up at all. I found articles online that say serving xhtml as text/html is bad and it lists reasons, but I'm pretty sure I do that and my pages look the way I want, tested in a number of browsers (with some css tweaking of course).
-
Jul 9, 2008, 20:39 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
Browsers do several things when determining how to render a page. They look at the Content-type header. The <!DOCTYPE and to a lesser extent, <meta http-equiv='Content-Type'
If things don't "jive", the browser may render the page in "quirks" or "almost standards" mode (doctype switching), which may not be what you wanted.
AFAIK, most servers serve php and html pages as text/html, but if you have PHP you can send a Content-type header().
Note IE (>=6 anyway) doesn't recognize the application/xhtml+xml header and won't render the page.Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Jul 9, 2008, 22:07 #3
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
See How do I serve XHTML with the proper MIME type? in the XHTML vs HTML FAQ.
You need to make the server send the proper Content-Type header, or use a server-side scripting language and send it yourself.
No, that won't work. A user agent must know the content type before it starts parsing the document. In the case of HTML vs XHTML, a browser needs to know if it should use its HTML parser or its XML parser. They are very different.
It's not to do with markup as such, really. The content type is something you need to tell the recipient about whenever you serve a resource via HTTP. A browser or other user agent needs to know whether it's about to get an HTML document, an X(HT)ML document, a PNG image, a plain text file, an Excel spreadsheet, or whatever. And it needs to know this before it can make a decision about what to do with that resource.
It may or may not be 'bad'. The thing is that if you serve XHTML markup – or anything else, including a Word document or a JPEG image – as text/html, user agents are required to interpret it as HTML. In other words, you're not using XHTML at all if you do this.
The page may look the way you want (thanks to browser bugs and error handling), but it's not XHTML and you can't use any features that XHTML offers over HTML.
While it's considered okay (albeit pointless) to serve a subset of XHTML as text/html, it's important to understand that the document must still work if served as an application of XML. If you aren't aware of the fundamental differences between these two markup languages, chances are that it won't.
I recommend that you read the XHTML vs HTML FAQ thoroughly.Birnam wood is come to Dunsinane
-
Jul 10, 2008, 18:08 #4
I have a feeling the syntax differences aren't the fundamental difference you're talking about. I'll read the FAQs thoroughly and probably post some other questions.
-
Jul 10, 2008, 19:01 #5
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
This Opera page lists some differences in how pages are rendered http://www.opera.com/docs/specs/doctype/ and has links to Microsoft and Mozilla documentation.
- CSS size and position properties specified without a unit
- CSS size and position properties with a space between the number and the unit
- CSS class and ID selectors starting with a number
- The 'height' attribute in table rows (7.0-7.11)
- Vertical overflow in block elements with a specified height
- CSS properties are inherited into tables in Standards Mode
- Inline elements with a specified width are replaced by an inline block in Quirks Mode
- CSS font sizes are increased by one in quirks mode compared to Standards mode
- Opera is case-sensitive for CSS class and ID selectors in Standards mode
- Box-sizing is based on the IE/Windows border-box model in quirks mode
- The margins of the containing box are subtracted when computing percentage widths
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Jul 10, 2008, 20:52 #6
Ok, I read through XHTML vs. HTML FAQs and there's one concept I'm hoping you can clear up for me.
In the question 'Do I need the xmlns attribute in my <html> tag?' it says, 'Yes. That is what tells user agents that the document is, in fact, XHTML..'
In the next FAQ 'How does this MIME type thingy work?', I think I'm reading that the MIME type of the Content-Type header determines a real xhtml document or not.
So..these work together to serve a real xhtml document?
-
Jul 10, 2008, 21:53 #7
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes. Content-Type: application/xhtml+xml says that the document is an application of XML, nothing more. The XML namespace declaration is what tells user agents that this particular flavour of XML is XHTML.
You may also declare the MIME type as application/xml or text/xml. As long as you've got the right XML namespace declaration it will be recognised as XHTML.
With the right MIME type but no namespace declaration, you get generic XML.
The XML namespace declaration only makes sense if the MIME type says it's XML.
You need both to make it real XHTML. Funny enough, the doctype declaration has nothing to do with it.Birnam wood is come to Dunsinane
Bookmarks