2

I heard there is two ways to put the language attribute into the html tag.

The two ways are:

  • <html <?php language_attributes();?>>
  • and <html lang="<?php bloginfo("language"); ?>">

Is there a specific coding convention everyone uses or is it a case where its up to the programmer. The reason is because I want my wordpress theme to have proper code according to the coding conventions.

2

Use language_attributes(), it handles rtl and html or xhtml doctypes, and has a filter that users may want to hook in a child theme.

You can see how they differ in source:

  1. language_attributes()
  2. get_bloginfo()
  • @Milo When using the language_attributes(), within <html>, several errors appears when validating the code, unlike when using bloginfo('language'). Would you say it is a case that language_attributes() causes the least issues later on, during website development? – Craig Oct 8 '17 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.