Jump to content

New to XHTML


kiddo
 Share

Recommended Posts

I'm just start using XHTML ( I know HTML before ).I have read some tutorials of it from w3shools.com, and I have a few unanswered question (b'cause I don't know where to ask).In the tutorial said that strict XHTML (strict DTD) won't render a 'bad HTML', right?I tried to make a bad HTML and use the strict DTD.But it's still render the tag.Here is the HTML markup :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><body>  <h1 title="This is wrong" align="center" xml:lang="en" lang="en"> This is the first heading  <h1>This is the second heading </h2></body></html>

from the markup above, I expect that it won't render the heading,because it use a 'bad HTML'.Is there any wrong syntax in the markup?

Edited by Suwandi Halim
Link to comment
Share on other sites

I found xml:lang attribute in the XHTML tutorial.It appears that it has the same use as the lang attribute in HTML.So, what are these attributes uses?and why we use xml xml:lang attribute together with lang attribute?

Edited by Suwandi Halim
Link to comment
Share on other sites

A Strict DTD won't validate if you have elements or attributes that don't belong to it. But browsers will still try to render them.XHTML, when served as "application/xhtml+xml" won't render a page if it contains malformed XML. It only means that tags are case-sensitive, elements must be properly closed and parseable characters (<, &, ", ') must be escaped.The xml:lang attribute derives from XML. The lang attribute is from HTML. You use both of them so that both HTML parsers and XHTML parsers will understand them.

Link to comment
Share on other sites

To make your XHTML "served as application/xhtml+xml", change the file extension from ".html" to ".xhtml". IE8 and below don't support it though, so you'll have to use another browser (Firefox, Opera, Safari, Chrome) to open it.If you use the ".html" extension (i.e. make your XHTML "served as text/html"), browsers will process your document as if it's HTML, and thus, they'll forgive any errors as they do with "real" HTML.

Link to comment
Share on other sites

They tell the user agent (browser, search engine, screen readers etc.) what is the (human) language in the current element and all of its children. Logically, placing those on the <html> element means you're specifying the default language of the whole page.If you've ever tried to use Google's advanced search, you've probably seen the option to only search pages in a certain language. While Google does a lot of tricks to try and guess the language, it first tries to find a lang or xml:lang attributes, and if they are present, it takes it on blind fate that the specified language is correct. That's good for you, because depending on your content, Google might instead confuse your language for another one. I for one always place lang attributes on my pages, because Bulgarian is easily confusable with Macedonian and depending on the words used - Russian too. I wouldn't want users to find me when they search for Russian things.In addition, if blind users visit your page with a screen reader, the screen reader will choose the appropriate voice and parser based on the language. Different languages using the latin alphabet (e.g. English, German, Spanish, etc.) make pronounciation of words spelled the same way differently, so choosing the right language processor is vital to the user understanding you.

Link to comment
Share on other sites

They tell the user agent (browser, search engine, screen readers etc.) what is the (human) language in the current element and all of its children. Logically, placing those on the <html> element means you're specifying the default language of the whole page.If you've ever tried to use Google's advanced search, you've probably seen the option to only search pages in a certain language. While Google does a lot of tricks to try and guess the language, it first tries to find a lang or xml:lang attributes, and if they are present, it takes it on blind fate that the specified language is correct. That's good for you, because depending on your content, Google might instead confuse your language for another one. I for one always place lang attributes on my pages, because Bulgarian is easily confusable with Macedonian and depending on the words used - Russian too. I wouldn't want users to find me when they search for Russian things.In addition, if blind users visit your page with a screen reader, the screen reader will choose the appropriate voice and parser based on the language. Different languages using the latin alphabet (e.g. English, German, Spanish, etc.) make pronounciation of words spelled the same way differently, so choosing the right language processor is vital to the user understanding you.
Wow, that's a good explaination. It makes me understand now. Thx a lot.Anyway, is there any tips to build a 100% cross browser compatibility web page?or maybe approximately? Edited by Suwandi Halim
Link to comment
Share on other sites

1. Use ONLY valid and syntactically correct code. By "code", I mean all front end codes - (X)HTML, CSS, JavaScript, etc.2. Within your code, test for features, not browsers. This is most easily understood in the context of JavaScript - you should detect if a certain object exists, and assume the related feature exists if the object is present.3. Code for non-IE browsers first, and apply fixes for IE bugs afterwards. If you're doing fixes for IE versions earlier than the current one, enclose them in conditional comments.4. Test in all browsers as you go and before initial public release.5. Forget about pixel perfection. Not going to happen. But that shouldn't be a goal either. A few pixel taller/shorter letters isn't going to affect the workflow of your users, and in the end, their experience matters most.6. If a feature differs between non-IE browsers, avoid it, and instead try to find a way to do the same thing without it, until all public releases of the non-IE browsers do it in a close enough fashion. While you won't encounter any (considerable?) differences in long standing standards, the behaviour of some cutting edge things (such as HTML video, geolocation and border images) is still not set in stone, so it will likely differ across all browsers.

Link to comment
Share on other sites

I want to make a centered div in xhtml.I use this following markup to do it :

<div style="margin: auto;"> </div>

It works on Mozilla, but not on IE.How can I make centered div that works on both browsers?or cross platform compatible?And,I need a xhtml validator to validate the markup I write,but the offline one. It must be free of course.I try googling it, but what I found was php class to validate xhtml markups.But I don't know how to use it.So, I think an application or tools will be more easy to use.Any suggestion?@boen robot : nice tips... Thx

Link to comment
Share on other sites

centering is a CSS technique, not an (X)HTML one. To center a block level element like a div, use margin: 0px auto.
The element must also have a width specified since block elements, by default, will take up as much horizontal space as is available.As far as a validator goes, Firefox has an add-on which will validate your markup on the fly or you can go to http://validator.w3.org/ to validate your markup.
Link to comment
Share on other sites

The element must also have a width specified since block elements, by default, will take up as much horizontal space as is available.As far as a validator goes, Firefox has an add-on which will validate your markup on the fly or you can go to http://validator.w3.org/ to validate your markup.
darn, I keep forgetting the width part of that! also, I use that add-on extensively but was not aware that it could be used while you weren't connected to the internet. I tried it with Firefox in offline mode just to test it and it wouldn't display any status messages.
Link to comment
Share on other sites

centering is a CSS technique, not an (X)HTML one. To center a block level element like a div, use margin: 0px auto.
It works on Mozilla browser, but not on IE.I've tried it before.Is there anothter trick?So, to validate XHTML document I've to do it on the fly, right?I see....
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...