Work around for HTML stripping quotes in quirks mode? - html

when i tried to get as InnerHTML in Javascript, Firefox giving expected results. so that i can manipulate the dom elements, bu when i use the same working code, IE will strip out the quotation marks from the attribute pair. i am wondering is there any work around to solve this problem. and if possible can any body tell me why does it renders, because of quirks mode or what ? as i have iframes in pages.
DocType which i have in my page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expected :
<span id="someID">Ravi <span class="SomeClass">assignment </span>submission</span>
Output
<span id=someID>Ravi <span class=SomeClass>assignment </span>submission</span>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> doesn’t trigger quirks mode, it triggers standards mode just fine.
Why do the missing quotes bother you? If you want to manipulate the DOM elements, you don’t need the innerHTML string.

Related

background position in mozila and ie

I have this css
.viewimages{position: fixed;}
which works in chrome and Mozilla but the position isn't picking in i.e instead it is floating left yet it is suppose to position itself in the center.So any help
This should be fixed by adding a doctype to the top of your HTML document, forcing the browser to be a bit more standards compliant:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Or if you're using XHTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This will work unless you are relying on quirks mode to render the page then unfortunately there's no support.

HTML Basic - Validation

I know this is a really basic question...
Are these the same for close -
<iframe src="includes/captcha/captcha.php"></iframe>
<iframe src="includes/captcha/captcha.php"/>
And
<div id="container_join_messages" class="shadow"></div>
<div id="container_join_messages" class="shadow"/>
Just wanting to see if I can drop the extra tag at the end and still validate.
Using this doc type
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
According to What are all the valid self-closing elements in XHTML (as implemented by the major browsers)? XHTML capable browsers support self-closing on every element. I've never tried validating such a document myself though.

CSS not showing properly in IE(Reason was doctype defination)

I am working on this personal project and the sign-in screen of the website goes completely haywire in IE-9
Can someone please suggest me how can I fix it? The webpage is at
http://www.ayeboss.com/users/login
Try opening it in FF and IE and you will see the difference.
Any inputs will be highly appreciated
Your page is being displayed in Quirks Mode, because you don't have a doctype.
Add this, the HTML5 doctype, as the very first line to resolve the problem:
<!DOCTYPE html>
You should always add a doctype to trigger Standards Mode.
well some problems with your html and some with CSS. you are trying to use CSS3 but not completly..
1st mention DOCTYPE
2nd margin and paddings are bugy in IE.. in IE the become double to normal value.
(i.e like if you set margin for Fireforx but they appear double in IE most likly.)
3rd you have use CSS3 properties ..
-moz-border-radius (it only works in FF) so if you want to see this property in action in IE .. try -webkit-border-radius. and read this article border-radius
for gradient gradient
replace your html tag with this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
If you are using html transitional use this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
If you are using XHTML 1.0 transitional go for this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
If you never want your browser to behave as an old version. Then add this:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

What is the functionality of !DOCTYPE?

We often see <!DOCTYPE ...> as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
What's the functionality of !DOCTYPE?
The most significant use of DOCTYPE is to switch a browser between Quirks Mode and Standards Mode rendering.
This functionality came about because of the "broken" rendering in old versions of IE. It was realised that if Microsoft just "fixed" the IE rendering engine lots of existing sites would not render properly. So the way it works is if you put any valid DOCTYPE declaration at all in your page the assumption is that you know what you're doing and your browser will render in a standards compliant way, and if you don't put one in it will render in the old "wrong" way.
This was originally done in IE for the Mac, but this behaviour is the same in all versions of IE since IE5, and Firefox, Chrome, Safari and Opera.
What the DOCTYPE is supposed to be is a Document Type Definition. HTML is subset of SGML (as is XML). The DTD tells a parser which syntax you are using. So in a webpage your DOCTYPE should match the version of HTML you are using.
It tells to the validator which version of HTML do are you using. A browser use this information to render the page correctly.
Here are correct version of DOCTYPE:
HTML 4.01 Strict, Transitional, Frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Strict, Transitional, Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
HTML5
<!DOCTYPE html>
Mainly for compatibility.
Modern browsers don't need it anymore. See this HTML file that does not have a !DOCTYPE:
<p>hello</p>
The browser automatically inserts the !DOCTYPE.
But that's only in modern browsers.
In IE8, some css properties only have functionality when the doctype is stated.
So, if you don't need to support ancient relic browsers, you don't need it. But it has become a programmer custom!
———
Update:
The doctype used to require a DTD URL. The DTD defines all the elements in the document. If you are using the HTML 4.01 DTD, HTML 5 elements will not work.
But it is not all sunshine and butterflies.
Some features will break. Without a DOCTYPE, the green square fills up 50% of the width:
div {
width:50%;
background-color:#00ff00;
}
<div>div</div>
But with one:
div {
width:50%;
background-color:#00ff00;
}
<!DOCTYPE html>
<div></div>
However, stack snippets automatically adds a !DOCTYPE, so you can't see it here.
It tells your browser which version of HTML it is loading making the load time a bit quicker as the browser know what to expect.
The doctype is a standard defined by the w3c - when you hear about standards based web development this is what they are talking about. The idea of using the doctype is you create valid HTML that follows the doctype.
If you are clever you can actually write your own doctype.
The main (practical) purpose of DOCTYPEs is to force IE from "quirks mode" to "standards-compliant mode", both euphemisms for "horribly broken mode" and "slightly broken mode" (respectively).
In other browsers, the page responds normally without the !DOCTYPE, with these exceptions:
try using the z-index CSS property in Internet Explorer. In quirks mode, it does not work. You need to be in standards-compliant mode for it to work. The easiest way to do this, of course, is with a DOCTYPE.
Browsers behave differently with and without a !DOCTYPE. Here's the code:
<div>some text</div>
<style type="text/css">
div {
background-color:#00ffff;
height:10%;
width:10%;
}
</style>
This web page renders differently when it has a !DOCTYPE and when it does not.
Without a DOCTYPE:
With a DOCTYPE:
Without a !DOCTYPE, the element is sized according to CSS. But with the !DOCTYPE, it is sized according to the element.
The !doctype was not that simple back then. You had to specify a DTD URL:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The DTD looks something like this:
<!ENTITY % HTML.Version "-//W3C//DTD HTML YOURVERSION Transitional//EN"
-- this is a comment.
-->
<!ENTITY % HTML.Frameset "IGNORE">
<!ENTITY % ContentType "CDATA"
-- media type, as per [RFC2045]
-->
<!ENTITY % ContentTypes "CDATA"
-- comma-separated list of media types, as per [RFC2045]
-->
<!ENTITY % Charset "CDATA"
-- a character encoding, as per [RFC2045]
-->
<!ENTITY % Charsets "CDATA"
-- a space-separated list of character encodings, as per [RFC2045]
-->
<!ENTITY % LanguageCode "NAME"
-- a language code, as per [RFC1766]
-->
<!ENTITY % Character "CDATA"
-- a single character from [ISO10646]
-->
<!ENTITY % LinkTypes "CDATA"
-- space-separated list of link types
-->
<!ENTITY % MediaDesc "CDATA"
-- single or comma-separated list of media descriptors
-->
<!ENTITY % URI "CDATA"
-- a Uniform Resource Identifier,
see [URI]
-->
<!ENTITY % Datetime "CDATA" -- date and time information. ISO date format -->
<!ENTITY % Script "CDATA" -- script expression -->
and so on an so forth.

DOCTYPE tag problem

is it possible to use DOCTYPE tag in line 2 or 3 or ... and css works good ? (not line 1)
tag :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Yes. As long as it comes before your <html> tag, you should be fine. This might happen, for instance, if you put an XML declaration above it. The xml declaration, however, must occur at the very beginning of the file.
Example:
<?xml version='1.0' charset='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>This is an example</title>
</head>
<body>
<h1>This is an example</h1>
<p>
You might even put an xml stylesheet declaration up above your
DTD declaration, which would look like this:
<code><?xml-stylesheet type="text/xsl" href="transform.xsl"?></code>
</p>
<p>But you still can't put any HTML above your DOCTYPE. Sorry.</p>
</body>
</html>
Seems like you are very persistent about doing strange things with your doctype. It's best you always use it AND put it on the first line of your document. If you go arround the web you'll find that almost every website has it like that.
Is there a reason why you don't want to do so?
IE6 will fall into quirks mode if you put anything (including an XML declaration) before the Doctype. So - "no".
Most browsers will fall into quirks mode (AFAIK) if any content appears before it. Don't use hosts who prevent you from using valid markup.
by standards, the DOCTYPE should be the first line. why would you not want to put it there anyways?