VisualForce Pages automatically including "loose.dtd" in all pages - html

Whenever I write a VF Page, I see the "loose.dtd" file being included automatically in the HTML code(Firebug/Developer Console).
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"
Please suggest an approach to remove this, as it makes my HTML code to conflict with IE.

This is documented in salesforces documentation. The default doctype is loose, if you want a stricter or different doctype you need to specify it using the docType attribute.
Eg
<apex:page controller="Pagecontroller" docType="html-5.0">
More info here: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_page.htm

Related

DOCTYPE HTML in html file

Why is <!DOCTYPE html ... > used in html file?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The DOCTYPE Declaration (DTD or Document Type Declaration) does a couple of things:
When performing HTML validation testing on a web page it tells the HTML (HyperText Markup Language) validator which version of (X)HTML standard the web page coding is supposed to comply with. When you validate your web page the HTML validator checks the coding against the applicable standard then reports which portions of the coding do not pass HTML validation (are not compliant).
It tells the browser how to render the page in standards compliant mode.
For more information refer to this "<!DOCTYPE html>" What does it mean?
It tells the browser that the following code is to be treated as a particular version of html code.
The browser knows then to look for an open HTML tag <html> and treats everything like html until it reaches the close HTML tag </html>
<!DOCTYPE html> is all that's needed now.
The term DOCTYPE tells the browser which type of HTML is used on a webpage. Here is link of official page which explains your query why and what is
<!DOCTYPE html>
A doctype defines which version of HTML/XHTML your document uses. You would want to use a doctype so that when you run your code through validators, the validators know which version of HTML/XHTML to check against
The declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
In HTML 4.01, the declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
Tip: Always add the declaration to your HTML documents, so that the browser knows what type of document to expect.
The <!DOCTYPE html> declaration is used to inform a website visitor's browser that the document being rendered is an HTML document. While not actually an HTML element itself, every HTML document should being with a DOCTYPE declaration to be compliant with HTML standards.
For HTML5 documents (which nearly all new web documents should be), the DOCTYPE declaration should be:
<!DOCTYPE html>
Show to the browser than the file is a HTML5.
Is followed by the lenguage etiquete according to HTML5 good practiques.
<!doctype html>
<html lang="es">
In this case the second line indicates to the browsers than the file is in example, spanish in this case <html lang="es">
is important for building an HTML documents it is not just HTML but it is an instruction to the web browser about what version of HTML the page is written in.

Difference in DOCTYPE's

I am new to HTML concepts, but I had issue with my web page. It was not able to load properly on IE10 then I googled further and changed the doctype from
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
to
<!DOCTYPE HTML>
surprisingly it worked
I tried reading regarding this DOCTYPE got to know that the mentioned DTD is used to render the web page. But i was not able to gather much information. can anyone tell me what is actually making the difference there ??
According to HTML standards, each HTML document requires a document type declaration. The "DOCTYPE" begins the HTML document and tells a validator which version of HTML to use in checking the document's syntax.
Doctype you used earlier :-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
as you can see belongs to html 4
and doctype you used later
<!DOCTYPE HTML>
is HTML 5. the latest standard for web. That's why it's working in IE10.
The difference is HTML 4.01 and HTML 5. The doctype for HTML 5 is simply:
<!DOCTYPE HTML>
There could be many different reasons for why the rendering is different. For a well formatted HTML 4 document there shouldn't be any difference between HTML 4 and HTML 5. But if you are using HTML 5 features then declare the document as HTML 4 you may be triggering quirks mode.
"Quirks" mode is what browser manufacturers call when they need to emulate features of older versions of the browser engine including bugs (yes, emulate bugs, because some web developers use bugs to trigger features in their code). You can think of quirks mode as HTML version custom-to-this-browser-and-only-this-browser.

Necessary for the URL in html DOCTYPE?

I have a question regarding html doctype, is the url for doctype necessary? I saw it in some production codes that has only
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
without the URL like
"http://www.w3.org/TR/html4/loose.dtd">
I understand that doctype will let browser determine layout mode, either standard or quirk mode, but im uncertain whether do we need the url, does it make difference without the url?
The DOCTYPE header tells your browser what version of html the webpage is written in..Hence the browser will try to interpret the content of the page based on the version...with html4 and below the doctype string is needed.
However With HTML5 there is no need for a reference string..you can simply use
<!doctype html>
short simple and easy
(The DOCTYPE is retained in HTML4 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers)
It is valid HTML 3.2 to omit the URL. Probably not valid HTML 4 however
source
If you have noticed <!doctype html>, that's to indicate HTML5.
Doctype has a public identifier (e.g. -//W3C//...) followed by system identifier (e.g. http://www.w3c...). Notice that HTML2 and HTML3.2 had no system identifier (http://www.w3.org/QA/2002/04/valid-dtd-list.html). Otherwise you have to use a system identifier URL to call the doctype correct.
http://www.w3schools.com/tags/tag_doctype.asp provides some more literature regarding doctypes. Also note an interesting list of doctypes here: https://www.totalvalidator.com/support/doctypes.html. W3C documention is here: http://dev.w3.org/html5/html-author/
In HTML 4.01, the <!DOCTYPE> declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
but add the <!DOCTYPE> declaration to your HTML documents, so that
the browser knows what type of document to expect.
Like as follows :
<!Doctype html>
What you mentioning about is "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">"
This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.

Why and how to use <!DOCTYPE>? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What's up, Doctype?
HTML: What is the functionality of !DOCTYPE
Okay, when I first learn HTML, I basically learn from trial and error as I went along, and didn't really sit down to properly learn it as far as I can remember. As a result of this, I've missed out a lot, and therefore, I've decided to start from the basics for my own benefit. :) So here I am, (re-)learning HTML.
Now, my question - the <!DOCTYPE> tag confuses me more than any other HTML tag I've ever come across, so I've come here to clear up any questions I have regarding it so I can use it confidently. :)
Firstly, can someone explain to me why it's necessary to use a <!DOCTYPE> tag in your webpages? They work fine without them, don't they? I've read that it is so it can be validated against the standards of the W3C, but that's all I know. A little more detail would be appreciated. :)
Secondly, after reading up on it, I'm still confused as to what exactly goes in my <!DOCTYPE> and how to type it out. For example, this is one kind of DOCTYPE I've seen used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Yet I've also seen other variations, and from what I've read, there are different DOCTYPES to validate against - it's all so very confusing, which should I use in my webpages if I was going to use one?
W3C has a pretty good answer to this at http://www.w3.org/QA/Tips/Doctype
Why?
Why specify a doctype? Because it defines which version of (X)HTML
your document is actually using, and this is a critical piece of
information needed by some tools processing the document.
For example, specifying the doctype of your document allows you to use
tools such as the Markup Validator to check the syntax of your
(X)HTML. Such tools won't be able to work if they do not know what
kind of document you are using.
But the most important thing is that with most families of browsers, a
doctype declaration will make a lot of guessing unnecessary, and will
thus trigger a "standard" rendering mode.
Basically if you leave it out, the browser will try and guess what rendering mode to use, and it might cause some unexpected results.
it basically tells the browser how to interpret the page you're sending it. If you don't send anything, it has to make guesses. Some constructs are valid in a format while invalid in others, etc. Some browsers may display your page correctly while others don't. So yes, do choose and send a DOCTYPE.
There are several doctypes you can use, xhtml, html strict, html transitional, 4.01, etc. You can see a list of valid types here ... http://www.w3.org/QA/2002/04/valid-dtd-list.html
The declaration refers to a Document Type Definition (DTD). A DTD specifies the rules for the markup language, so that the browsers render the content correctly.
Going forward, for html5 compliance, the correct tag is simply:
<!DOCTYPE html>
You set a doctype to say to your browser or somthing else what you going tho do. Its look like what you do whit a business card
There are several doctype's. The most yoused doctype's are transitional:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd">
The some stricter doctype is: (see "strict")
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Also you can youse a speciffie doctype declaraition for youse a frameset. But this is outdated, frameset is a unnecessary for my but i will show you the doctype for this. But forgot the framesets this is an not useful html element whit html5. Here see you the follow frameset doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
And at last. You can youse a language attribuut for your the doctypes. This can youse by html and xhtml.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Is the "xmlns" in <html xmlns= ...> needed when the page is served as HTML 4.01?

I like to serve the page as HTML 4.01, because XHTML is not really taken as XHTML in some browsers anyway, but Facebook's OpenGraph meta tags requires:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
but since the DOCTYPE of the page is not XHTML, does it matter if the xmlns are there, and should the page be made into DOCTYPE XHTML instead?
(actually, if the page is HTML, the xmlns is kind of confusing, as it is not really XML, but the Facebook page doesn't talk about how to add the meta tags in a page that is HTML 4.01)
For HTML 4.01 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
For HTML 4.01 Trasitional:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The xmlns stuff you see in the facebook example are XML namespaces and their purpose is to allow the developer to include custom tailored information to HTML documents.
Think of it like folders in a filesystem.
So when facebook declares:
xmlns:fb="http://www.facebook.com/2008/fbml"
They are defining a "folder" in which their custom tags/attributes/properties are stored, so:
<meta property="fb:admins" content="USER_ID"/>
...where the important part is "fb:admins" is the same as having this on your hard drive:
/fb/admins.txt
which contains the USER_ID value.
So it's just a way to keep data organized and separated.
Hope this clears things up for you.
It won't be valid HTML 4.01 if you add xmlns attributes, but it most likely won't affect the rendering.
I wouldn't use HTML 4.01 if I was you. HTML 5 is the new standard, and you should use it.
Those are XML namespace definitions they exist as a way to avoid collisions in XML element names.
Since this is facebook's protocol, they are the ones that define the namespaces.
It has "nothing" to do with how the page is served.