What is the 'lang' attribute of the <html> tag used for?

前端 未结 5 2201
北海茫月
北海茫月 2020-12-07 22:59

In HTML, it\'s good to have a lang attribute in , e.g. .

How is this useful?

If th

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 23:32

    You asked "how is this useful".

    "The attribute can be used to declare the language of a Web page or a portion of a Web page. This is meant to assist search engine spiders, page formatting and screen reader technology"

    Source: http://symbolcodes.tlt.psu.edu/web/tips/langtag.html

    No mention of translation - but often a search engine spider will not want to parse through a document "in the wrong language" - its index file will grow (lots of new words), and the results will not be useful to the user (who cannot read the language, and who is using the wrong search terms).

    The advent of smart translation technology (like Google's, referred to above) means that some search engines can see a page in one language, translate it, and figure out that someone searching for "cow" may be interested in this page that mentions "vache" and has .

提交回复
热议问题