Forum Moderators: open

Message Too Old, No Replies

Transitional > xhtml1-strict

what happens when i change doc type?

         

santapaws

4:09 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



Hi Guys!
All my pages are declared as
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

i want to use a css menu that requries a declaaration of
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

So if i simply switch the doc declaration on all pages that use the menu what are the implications? Whats the non-tech answer to what are the differences between the tags. Thanks.

p.s. i dont even understand why simply using css requires the change for the menu to work.

rocknbil

7:06 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard santapaws - there is a bit more complicaton to this. First, this doctype

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

Is not a valid doctype. Your documents are rendering in "Quirks" mode as opposed to "Standards Compliance" mode. The correct doctype for 4.01 trans. is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

The difference between the two is that some CSS functions will cease to work if you don't apply valid CSS selectors. For example, in quirks mode ff0000 will render as red, but in standards mode it won't work - you need to use #ff0000.

This, really, is the answer to the question - you will need standards mode rendering for the menu to work, apparently. You might just try using a 4.01 transitional as demonstrated above - I don't **think** there are any CSS selectors specific to XHTML.

Quirks mode allows more "wiggle room" for sloppy or improperly coded pages, but you generally have more trouble getting the pages to look the same in different browsers. By coding to standards, many cross browser issues go away (but certainly not all!)

The XHTML doctype you posted is also standards compliant doctype, but you will also have other restrictions specific to XHTML. The XHTML doctype is often used only because some think it's the "latest and greatest." XHTML was intended to apply the extensibility of XML to HTML documents, if you're not doing any of that, there's no reason to use the XHTML doctype.

Choosing the right doctype [webmasterworld.com]

With XHTML you will have to add closing slashes to all "empty" tags, <br> becomes <br />, <img> becomes <img />.

ratman7

7:22 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



...if you're not doing any of that, there's no reason to use the XHTML doctype.

He's right, there is no technical reason to use xhtml over html 4 if you are serving it as text. Personally, I like xhtml as it forces your syntax to be a little cleaner in order to validate -- especially if you code in strict mode.

tedster

7:28 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I like xhtml as it forces your syntax to be a little cleaner in order to validate -- especially if you code in strict mode.

So does html 4.01 strict - and there's no downside with MIME types, etc. As I see it, moving from a transitional doctype to a strict doctype is the important step, not going from html to xhtml.

santapaws

7:56 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



ok thanks guys thats pretty cool.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

with that the menu works fine. Now does this mean i dont need to chnage any code on my current pages? I just need to watch for anything not rendering correctly? And this is a standards compliant mode, not a quirks mode?

rocknbil

7:33 pm on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should. You can check it in FireFox: right-click on the page and select "View Page Info." On the general tab, you will see the render mode.

The thing to watch for is if something doesn't render as expected, look to how you have the CSS specified. This can be debugged by running the CSS through the W3C CSS validator. The previous color comment is a good example.

Another example (I think?) in standards mode quoting a BG image won't work:

background: #ffffff url('images/myimage.gif') top left repeat-y;

you need to use no quotes

background: #ffffff url(images/myimage.gif) top left repeat-y;

penders

11:18 am on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Another example (I think?) in standards mode quoting a BG image won't work:

IMHO, using quotes (single or double) around the image URI is entirely optional, whether in standards mode or note. However, if the filename contains certain special characters (commas, spaces, quotes etc.) then you must use quotes to delimit the URI OR escape the special characters - best avoid the 'special' characters in the first place and avoid the need for the quotes (IMO) - W3C on 4.3.4 URLs and URIs [w3.org]

If you are going to use a valid DOCTYPE then you should really run your page through an HTML validator as well (eg. [validator.w3.org...] since you are now stating that your DOCument is of a particular TYPE. An error in the rendering of your page could be caused by an error in your source, that the validator would pick up.

MoneyXtreme

12:46 pm on Dec 24, 2007 (gmt 0)

10+ Year Member



I think a big misconception of the <!doctype> tag is that lot of people assume that it is used for the person coding the page, to fit his coding style.
The!doctype is to tell different browsers how to render a page. So its used to fit the visitor's browser,..or what you expect your users to be browsing with.
trans. will let some stuff not render and still show the remaining stuff if the user is using, let say, a cellphone to view your site and the stuff that cant be seen just wont show and wont bug the page, strict wont do that, the page will not show. In-game browsers like eve online, etc, it will act the same way.
but it is true to say that strict needs to be coded in only one right way.

As for xhtml and html,...
xhtml will tell your browser that script, database, etc, will be present, so will take less time since it will be in mode of knowing its coming. But since xhtml is in fact just an improvement(an update) of html, both are pretty much the same for standard pages with text and images.

so i would use html for plain pages with text and graphics,
and use xhtml with .php, .asp, scripts, if my page needs a database, etc...

[edited by: encyclo at 2:52 pm (utc) on Dec. 24, 2007]
[edit reason] no links to personal sites please [/edit]

Fotiman

7:34 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




As for xhtml and html,...
xhtml will tell your browser that script, database, etc, will be present, so will take less time since it will be in mode of knowing its coming. But since xhtml is in fact just an improvement(an update) of html, both are pretty much the same for standard pages with text and images.

HUH?!
Do you actually believe that? If so, it's time to go back to school. The use of xhtml does NOT tell the browser that script, database, etc. will be present, and will not take less time. Likewise, xhtml is NOT an "improvement" of html. xhtml is a reworking of html into xml format.

Please take a look at this thread:
Why most of us should NOT use XHTML [webmasterworld.com]

pageoneresults

7:39 pm on Dec 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I was going to reference the same thread Fotiman did. But here's something to think about. Most of the WYSIWYG Editors are configured out of the box for XHMTL. Many of the Open Source stuff is XHMTL. Most Programmers are generating XHTML.

So, what do you do? I say plan carefully. If you have third party applications involved, theirs will most likely be XHTML. Getting them to change it to HTML is going to be a challenge. Believe me, I've just finished going through a similar challenge. After that experience, I'm not too convinced that switching back to HTML is in my best interest at the moment. For many, they see that as taking a step backwards.

Solution1

7:37 am on Dec 30, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



Technically, XHTML is rendered as HTML, as the current situation is. So in actuality, it won't make any difference whether you mix XHTML with HTML. It will just not look neat.

[edited by: Solution1 at 7:38 am (utc) on Dec. 30, 2007]