PDA

View Full Version : Does it make any difference if I change lang in html tag ?



abduraooft
Aug 11th, 2007, 10:27 AM
Hi guys,
A simple question, does it make any effects to my document if I change the value of lang attribute ?

Or Can I make any considerable effects in my document by it?

regards,
art.

koyama
Aug 11th, 2007, 02:26 PM
A simple question, does it make any effects to my document if I change the value of lang attribute ?
According to W3C the purpose of specifying a language via the lang attribute (or the HTTP "Content-Language" header) is to assist search engines and user agents in various ways [1]

As for search engines, I guess that specifying the language may still be important for helping them determine which language the page is written in [2].

But when one considers Google's growing set of language tools I wouldn't be surprised if specifying the language is, or no longer will be necessary when it comes to search engine optimization. Google can probably determine the language just by looking at the content and doing dictionary look-ups. I'm not sure what stage we currently are at.

[1] http://www.w3.org/TR/html4/struct/dirlang.html
[2] http://seobloguk.blogspot.com/2006/12/specifying-lang-attribute-for-seo.html

abduraooft
Aug 11th, 2007, 02:43 PM
Thanks koyama,

I had a search on this forum, and found many related posts, but couldn't find any answer to my question. You are great. (BTW I'm helpless to 'spread' some reputation, sorry...)

regards,
art

croatiankid
Aug 11th, 2007, 02:45 PM
There's an article (http://www.w3.org/International/tutorials/language-decl/) at w3.org that discusses it. It can help screen readers and SEs.

I usually just use the lang attribute of the HTML tag, and omit its closing tag (as well as the HEAD and BODY tags), which you can see in my site's code. And I don't bother with the meta tag.

abduraooft
Aug 11th, 2007, 02:50 PM
I usually just use the lang attribute of the HTML tag, and omit its closing tag (as well as the HEAD and BODY tags), which you can see in my site's code. And I don't bother with the meta tag.

Wow!. A new piece of info. But now I'm totally confused about the structure of a valid html document:eek:

When I miss/make error on closing a simple tag like <a>, <span> etc, the validator will point out the error.
Here you have completely omitted head, body, and omitted closing of <html>.
Am I going downwards (I'm losing all my poor understanding about html)?

croatiankid
Aug 14th, 2007, 10:05 AM
When I miss/make error on closing a simple tag like <a>, <span> etc, the validator will point out the error.


That's because they must have closing tags (it is an error). Here (http://www.w3.org/TR/html401/index/elements.html)'s a list of the HTML 4.01 elements and you can read, among other things, which tags may be omitted.

The reason you can omit tags like the HTML HEAD and BODY opening and closing tags as well as P LI etc. closing tags is because their respective elements' rendering is unambiguous to the parser (if you keep the TITLE tags at the top of the document, it'll still know what they're in the HEAD element). Some of this tag omitting will be available in HTML 5 as well.

abduraooft
Aug 14th, 2007, 11:19 AM
Aha.. that's a good link. I think it's very hard to locate such links from the site, even though w3.org contain all stuffs (may be due to its vastness) .

Do these optional-tags make any problem to browser? (I mean processing delay)

The tags <tr>,<td> are listed like a closing-tag optional. But we'll get error on w3-validation. Any sort of contradiction there?

(Apologies for the mismatch of thread title and current content.)

thanks,
art.

croatiankid
Aug 14th, 2007, 01:11 PM
It doesn't when I try.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<title>dkja</title>
<table><tr><td>dadk</table>validates.

The w3c site isn't very navigable, but they have a search that I use basically every time I'm looking for something.

abduraooft
Aug 15th, 2007, 12:28 PM
Yes, that's fine, the problem was on my doctype .
I was trying on an XHTML 1.0 Strict. I hope the above rule may not be followed by Xhtml.

Thanks,
art.

croatiankid
Aug 15th, 2007, 02:04 PM
XHTML is a different story. In XHTML, if the tag doesn't exist, the element doesn't. And, as an xml language, you need to close all tags in the proper order.

Arbitrator
Aug 15th, 2007, 07:01 PM
A simple question, does it make any effects to my document if I change the value of lang attribute ?

Or Can I make any considerable effects in my document by it?Automated technologies can use it to tell the language of your document. It might be the browser, a search engine, or assistive technology. In Firefox, at least, you can right‐click things on the page and select ďPropertiesĒ to get the language if itís been specified by the author.

You can also use the lang pseudo‐class. For example, say that you want all Latin text to be italicized: :lang(la) { font-style: italics; }. Or, perhaps, you want all non‐English text to appear in red: :not(lang(en)) { color: red; }. Of course, this ignores the fact that Internet Explorer lacks support for the lang pseudo‐class and that the not pseudo‐class, being part of a CSS3 Working Draft, is not yet well‐supported.


When I miss/make error on closing a simple tag like <a>, <span> etc, the validator will point out the error.
Here you have completely omitted head, body, and omitted closing of <html>.
Am I going downwards (I'm losing all my poor understanding about html)?There are four implied elements in HTML: html, head, body, and tbody. Both their start and end tags may be omitted and the tags will automatically be added by the browser if they are. As a result, the first three elements will be present in every HTML document and the last will be present in every HTML document containing a table. There are a bunch of seldom‐mentioned tricks like this in HTML, but most of them are not supported by major browsers. This one happens to be supported by all of them, I think, though. Still, I would avoid it since itís bad for indentationís sake and confusing when you manipulate the document via scripting, style sheets, etc.

None of this is acceptable in XHTML; element omission is not allowed in XML and most of the trick features have been eliminated to make it easier to implement an XML parser.