LoginSignup
34
31

More than 3 years have passed since last update.

<html lang="ja">は何のために書くのか

Last updated at Posted at 2017-05-26

そもそもlangとは?

HTMLのlang属性は、要素内で使用されている言語を表記する属性。(langはlanguageの略。)
<html lang="ja">は、html要素内で使われている言語はjaという意味。(jaはjapaneseの略)

サイトによっては一部だけ英語などの別の言語を使用することがあると思いますが、その場合は、英語を使用する要素だけ別にlang属性を指定する。

何のために書くのか

文章を表示する方法は、言語ごとに違う。
例えば、英語は単語と単語の間にスペースが必要。しかし、日本語の文章にスペースが入っていたらおかしい。
そのため、ブラウザに対して使用している言語を認識させる必要がある。

参考
http://kouritool.com/html-seo-jijou/langja%E3%81%AF%E4%BB%8A%E5%BE%8C%E9%87%8D%E8%A6%81%E3%81%AB%E3%81%AA%E3%82%8B/
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1284999462

34
31
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
31