Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE just dislikes strict absolute divs?

Status
Not open for further replies.

Kuloch

Programmer
Jul 28, 2004
13
US
Was about to post asking if it was a ruleset problem, but a quick check for curiosity (need to do those more...) on my Firefox/Gentoo system shows it's just an IE bug (or non-compliance - same thing). Firefox works like expected, but I'd like to make IE work right.

I made a few example pages, for convenience.

I have a couple pages with absolute floating div tags. My problem is that if you try to highlight any text in either of the two floating divs (all but the very top centered h1 tag in the examples), it'll do only a block of the entire page prior to or after your starting point. This is in IE 6.0 on both WinXP and Win2k, for reference.

While the page technically looks fine, it's rather irritating to me and makes the page less useful due to inability to copy/paste anything easily.

This occurs in all the files linked above except html-trans.html, which begins with:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

It also works when no doctype is declared, but I didn't bother making a copy of that page as I'd rather not leave out the DTD.

What's very interesting is that if you add the doctype declaration url to the <!DOCTYPE, as in html-trans_with_url.html:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>

... or if you change the doctype to strict - leaving out the unruly dtd url - as in html-strict.html:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>

... it suddenly kills the drag highlighting again. And I couldn't get anything on the XHTML side to work.

I'd far prefer to run all my pages with strict compliance if at all possible - and better yet as XHTML strict. Is there any compliant hack to make IE not get all funky at the drop of a non-Transitional HTML DTD? Or am I just doing something fundamentally wrong?
 
Is there any compliant hack to make IE not get all funky at the drop of a non-Transitional HTML DTD?
Preceding the DocType with an HTML comment or an XML declaration will force IE into quirks mode without compromising standards mode for standards clients.
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html lang="en">

[COLOR=grey]or[/color]

<!-- my own comment here -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html lang="en">

<marc>
 
Just to add to things..
If you are creating a PHP page then the xml declaration will cause errors as the PHP parser sees the '<?' and assumes what follows is PHP. When it finds that it isn't it gets all tetchy and goes off to sulk.

Keep the PHP parser happy with

Code:
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Aha. Figures you have to mess with things to get IE to work right... Gotta love M$.

As always, thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top