How will a web application with XHTML 1.1 and frames behave on major browsers? - cross-browser

I am working on a web application which was built on XHTML 1.1 and also uses frameset and frames. Now the application runs only on IE (upto IE 8). I am trying to make changes so that it runs on major browsers. I have following questions:
Is XHTML 1.1 supported on major browsers and is it according to W3C standards?
I read that frames are obsolete in HTML5 but if I use XHTML 1.1 then are frames going to work in all browsers?
Is there any change in XHTML since XHTML 1.1 which I should incorporate?

There is XHTML5 (the XHTML syntax for HTML5). Specification, good blog post, another good blog post.
In essence, you can write HTML5 as if it was XHTML, by sticking to several rules.

Yes.
Framesets are neither valid in HTML5 nor XHTML 1.1, but they will continue to work in major browsers for compatibility reasons. If you need to use a frameset and want your document to validate you need to pick a document type that includes them such as XHTML 1.0 Frameset.
There is just XHTML5, which is nothing more than HTML5 written like XHTML, complying with the syntax rules as given by XML. But as mentioned in the comments, unless you go out of your way to serve your pages as XHTML you are never really authoring or serving XHTML, so you may as well stick with the more permissive syntax rules that come with the HTML syntax of HTML5.

Related

Question on syntax of doctype. And also in need of some suggestions

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
I have written my HTML and it is not working the way i wanted in all the browsers.When i gone through the google I found doctype should be declared at the starting of every HTML page.I have seen many wesbites some use HTML4.01 and some say XHMTL 1.0 . and some other webiste I found HTML 5.I dont know which is better to use.Im just learning these stuff from w3schools and some other websites.
Could anyone tell me which is better at the moment and powerful? and what the transitional , strict and loose mean in the doctype?
"http://www.w3.org/TR/html4/loose.dtd">
and what the above line stands for?If I have my own HTMl what should i put at that place? or it should be always the same http://w3..../ please clarify me. Thank You in advance friends.
The doctype stuff has always been pretty confusing, which is why HTML5 simplified it to this:
<!DOCTYPE html>
No more muss or fuss about DTDs or anything like that. Going on, I'd probably stick with this simplified form, since it's recognized by just about every browser nowadays.
To answer your question about the loose.dtd file, it's a "Document Type Definition" file. It's a special file that explains how HTML is formatted, and some validators will use it to see whether or not your HTML file is valid. Since there's been several versions of HTML (html 4.0, 4.01, XHTML 1.0 loose/transitional/strict, XHTML 1.1) each one has a different DTD.
That's the theory. In practice, it was rarely used that way. But as it happens, doctypes came around the same time as browsers started trying to follow standards in a consistent way. But the problem was that browsers needed some way to tell the difference between an old "quirky" webpage, and a new-fangled standards-compliant webpage. This is what DTDs were really used for: if a browser saw a DTD, it assumed the page should use the new rules instead of "quirks mode".
According to this Wikipedia page on the subject, the new HTML5-style doctype is recognized as standards-compliant (or "almost" standards-compliant) in just about any browser that's relevant, so for the most part, the confusion is over now.
HTML 4 is better for compatibility with older browsers. "loose" and "transitional" mean the same thing: "not strict", and are used when some deprecated attributes and elements are in use (e.g. presentational attributes). The part of the old doctype declaration that contains the URI points to the source URI of the original DTD file supported by the declaration. In this case, http://www.w3.org/TR/html4/loose.dtd is the location of the HTML 4.01 Transitional DTD.
HTML5 is more powerful, but all the new features of HTML5 need extra stuff like the HTML5 shiv to get working barely properly in some browsers.
The HTML5 doctype declaration is <!DOCTYPE html>. There is no PUBLIC keyword or URI as these aren't needed. The declaration is only there for the sake of standards mode. You can (and should) for the most part just use the HTML5 doctype in your existing old HTML documents, and they should still validate, even if you don't wish to try any of the new features yet on account of browser compatibility. 99% of browsers including IE6 understand the syntax of the HTML5 doctype itself and will render pages with it in standards mode.
http://www.w3schools.com/tags/tag_DOCTYPE.asp somewhat explains the differences between various DOCTYPEs. Basically, if you choose the strict doctype, you have to write a neater HTML/XHTML because many clumsy markup such as text directly within body element, framesets, etc. are not allowed.
Transitional doctype is less restrictive. Loose doctype is even less restrictive as the name suggests.
Having said that, these days, HTML5 is getting popular and it has a very simple doctype. Just <!DOCTYPE html>. It is worth learning HTML5 if you have just begun learning because it is supposed to be neater with more powerful features (especially for audio, video, images, etc.).
I do not think this syntax is easily understandable. You might get bests results with HTML5:
<!doctype html>

Which DOCTYPE declaration should we use?

I have read a number of books on DOCTYPE declaration and the three variations: strict, transitional and frameset.
But I am still not able to fully understand their difference and indeed am not sure which variation I should use when creating my website. In particular I don't understand the difference between strict and transitional.
could you please advise me?
Frameset is for documents that define framesets (non-frameset documents are then loaded into the frames). Frames are usually a poor design choice that cause more problems then they solve.
Transitional is, more or less, Strict plus things you shouldn't use (mostly because they have been replaced with CSS). There are a couple of exceptions, such as the start attribute which has some good arguments to support using it (but isn't often useful).
Strict is the core of HTML and is usually the best bet.
HTML 4.01 is the latest, finished version of HTML.
XHTML 1.0 is HTML 4.01 expressed in XML. It doesn't work in Internet Explorer unless you pretend it is HTML (which the text/html specification does allow).
XHTML 1.1 is XHTML 1.0 Strict plus the target attribute plus Ruby (not the programming language) plus a few other minor tweaks. There is no specification giving the OK to pretend XHTML 1.1 is HTML.
(Five years ago: HTML 5 is a draft specification, subject to change, and with many of the interesting bits not working without JavaScript backing them up in most browsers in use today. It lacks a mature validation tool.
HTML 4.01 is generally the best bet, but XHTML 1.0 is worth considering if you have an XML toolchain in your publishing system, and HTML 5 is worth considering if you have a need for something added in it and feel the risk of living on the bleeding edge is worth it.
In short: Use HTML 4.01 Strict unless you know why you need to use something else.)
Since this answer was originally written, HTML 5 has become a standard with good browser and toolchain support. It is the specification most closely aligned with how browsers actually work. An XML serialisation is available if you need XML support.
In short: Use HTML 5: <!DOCTYPE html>.
Use the HTML5 DOCTYPE:
<!DOCTYPE HTML>
Everything else is old and busted.
HTML5 > XHTML > HTML 4
Note: The DOCTYPE is only useful for validating your document and for triggering the most standards compliant mode in modern browsers. Other than that, it's worthless. So you might as well use the most modern version (HTML5).
First, are you using HTML or XHTML? I would recommend HTML - XHTML is a dead standard. HTML5 is the future (though who knows when that future will arrive) so I would go with HTML 4 transitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
This is the closest commonly-supported doctype to HTML5. You can use features of HTML5 like the <menu> tag and it will still validate.

Doctype, HTML 5

i have two questions:
1) was HTML5 released and if yes, when?
2) is doctype HTML 5 in use? or is it better to use one of these:
- HTML 4.01 Strict,
- HTML 4.01 Transitional,
- HTML 4.01 Frameset,
- XHTML 1.0 Strict,
- XHTML 1.0 Transitional,
- XHTML 1.0 Frameset,
- XHTML 1.1
<!DOCTYPE html>
That's the HTML5 doctype. All modern browsers support HTML5, although feature support is not necessarily complete.
As of March 2010, the specification is in the Draft Standard state, according to the W3C timetable HTML5 should reach W3C Recommendation state by late 2010.
Nice table of HTML5 Feature support shown here:
http://www.findmebyip.com/litmus/#target-selector
In my opinion, there's no reason not to use the HTML5 doctype.
A nice about this new DOCTYPE, especially, is that all current browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode - even though they don't implement HTML5. This means that you could start writing your web pages using HTML5 today and have them last for a very, very, long time
You can test some of the features of HTML5 here http://html5demos.com/ HTML5 dosen't get 'released' it is a specification that will get implemented into browsers bit by bit as time goes on. Although most popular browsers have implemented most of the standard to date.
You can find the latest draft on http://whatwg.org/html5.
There's a section about HTML 5's Doctype there.
Per a quick google search:
Question 1: yes, On January 22nd, 2008, W3C published a working draft for HTML 5.
http://www.w3schools.com/w3c/w3c_html.asp
Question 2: There are a few example html 5 sites to demonstrate what it can do, though they just use <!DOCTYPE html>:
http://html5demos.com/
"Note: HTML 5 is not a W3C recommendation yet! "
http://www.w3schools.com/html5/html5_reference.asp
Edit: As Marcel Korpel said... a working draft is not an official release.

What are pros to use XHTML 1.0 strict with content="text/html; over HTML 4.01 strict?

I'm sure everyone here knows that we cannot serve the pages with the correct MIME type (application/xhtml+xml) for XHTML without breaking IE compatibility, and that any content served with text/html will be parsed as HTML by any browser out there. So if the content is not parsed as XML.
I use a xhtml doctype only for one reason: it helps me find “errors” in my markup in a more stricter way compared to html. Even if my documents are served as text/html
Is there any other benefit to use XHTML 1.0 Strict with content="text/html; over HTML 4.01 strict at all? At present or and in the future.
if i'm already writing well formed valid HTML
4.01 strict and
not want to use any extra XHTML
features (SVG, Docbook, MathML, OFX,
etc),
never going to manipulate my XHTML
to XSL(T)
never goint to server document as
application/html+xml
None. You don't get any of XHTML's benefits. As far as the browser is concerned, it's getting weird HTML, not XML. If you want to get the benefits of XML, like extensibility and the stricter parser (if that's a benefit), you have to serve your page as application/xhtml+xml, and IE won't support it. Not to mention XHTML 1.0 is incompatible with 2.0, while HTML will always be future proof.
You may want to read this, among many others. In short, only use XHTML if you know you need to, otherwise it's useless.
XHTML also doesn't necessarily mean that the browsers will adjust to standards. Don't worry about the Standards vs Quirks mode stuff, it's something that has be mantained for backwards compatibility. When a browser encounters a page with a doctype (any doctype, HTML or XHTML), it will try to render it according to standards. It doesn't mean that it will render it just like the W3C says, it just means that it will try to (and maybe not succeed).
XHTML comes with default style rules (css), at least to some degree. And also some strict rendering rules. Any browser implementing XHTML doesn't have much leeway in how to present things, so in making an XHTML document, developers may find that their document renders the same in most browsers (although there are still some minor problems, especially with IE).
In later years this has improved greatly, and most XHTML documents' styles render the same way in "all" browsers.
You may also have heard of "standards mode" and "quirks mode".
Quirks mode is when (mainly IE) takes into account all the wrong things it's been doing in previous versions, and renders pages the way it used to, so it will render the way it was intended THEN.
Standards mode is a strict mode, which uses only standardized rules. This breaks some older pages, but lightens the load for many developers.
XHTML consists of all the elements in HTML 4.01, combined with the strict syntax of XML.

HTML DTDs - what's the point? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What are the different doctypes in html and what do they mean?
Being fairly inexperienced with certain aspects of web development (I've always concentrated more on the back-end than the front), can anyone give me their thoughts on whether I should worry about the DOCTYPE declaration made at the beginning of web pages?
Is the most common HTML 4.01 and should I build my web apps to conform to this standard?
John Resig (jQuery) has a say in that matter. Additionally, a DocType helps make MSIE6 use the right box model, and it also eases the pain of validating your site (this is a good thing for development; think of it as debugging).
You should definitely include a DOCTYPE as the first statement within your pages because it will switch Web browsers into standards mode. This means that they will at least attempt to render your page using W3C and IETF standards rather than by following the backwards-compatible model known as quirks mode.
Based on my own observations, there's more use of XHTML 1.0 Transitional now rather than HTML 4.01. XHTML 1.0 Transitional is a sort of halfway-house that gives you some of the benefits of XHTML without being too onerous.
DTDs are used for validation and entity definition. They roughly specify the syntax requirements for a certain markup language and version.
Validation might be done against a DTD by using a validator. Or, it might be done by the user agent during parsing (as is the case for some validating HTML/XML parsers). Entities defined in the DTD might be made available if the user agent supports that.
A DOCTYPE declaration is the markup language's way (in HTML and XML at least) to reference an inline/external DTD in the document.
Now, as far as browsers' HTML(text/html) parsers are concerned, the DOCTYPE declaration just controls the rendering mode (DOCTYPE switching). The mode will be Standards, Almost Standards or Quirks depending on the version of HTML referenced and whether or not a DTD URI is specified. The actual dtd is not used.
For example, an XHTML 1.0 Transitional doctype with a DTD URI might only put the browser in Almost Standards mode, where an XHTML 1.0 Strict doctype with the DTD URI should put the browser in Standards mode. Further, HTML5's doctype <!DOCTYPE html> will put all browsers in Standards mode and put IE8+ in Super Standards mode (so it behaves a little more like modern browsers when rendering). Generally though, the doctype has little effect on Javascript and DOM support (there are exceptions though, especially with IE8).
For browsers, since you almost always want full standards mode, all you really need is <!DOCTYPE html>. Anything more isn't going to help the browser. However, that doctype is for HTML5. If you want to conform to an HTML 4.01 DTD or an XHTML 1.0 DTD, you must use HTML 4.01 strict or XHTML 1.0 strict with the proper DTD URIs to get full standards mode.
If you want to conform to HTML5, you can test your syntax at http://validator.nu/. It doesn't validate against a DTD and is more advanced than DTD validation. It also reflects HTML 5 better than a DTD could and since HTML5 better reflects what browsers really support, it's syntax checking is more browser-world compatible.
If you want to conform to the HTML 4.01 or XHTML 1.0 DTDs, use the W3C validator. Just note that those DTDs don't reflect what browsers support and only roughly reflect the specs they're for. These DTDs are just more for catching rough syntax errors and for non-browser user agents that make full use of them. They also don't know anything about how browsers behave differently between text/html and application/xhtml+xml.
To read about browser Doctype Switching:
http://www.mozilla.org/docs/web-developer/quirks/doctypes.html
http://www.opera.com/docs/specs/doctype/
http://hsivonen.iki.fi/doctype/
Disregarding all good practices, the biggest reason people use a DOCTYPE such as XHTML 1.0 Transitional is to switch the CSS box model in IE to be the same as the rest of the browsers. This circumvents much frustration with CSS layout. It is explained here in more detail: http://css.maxdesign.com.au/listamatic/about-boxmodel.htm