WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/language attributes

Description

Displays the language attributes for the <html> tag. The possible language attributes are dir (text direction), lang and xml:lang. The choice of lang and xml:lang depends on the $doctype argument.

Usage

<?php language_attributes$doctype ?>

Parameters

$doctype
(string) (optional) The type of html document 'xhtml' or 'html'.
Default: 'html'

Return Values

(void) 
This function does not return a value.

Examples

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
...

(from wp-content/themes/twentyten/header.php)

May have the following output when the site language on the General Settings is set to English (United States):

<!DOCTYPE html>
<html lang="en-US">
...

Or if the language is set to Spanish the output may be:

<!DOCTYPE html>
<html lang="es-ES">
...

Notes

  • Uses: get_bloginfo() May call to get 'text_direction' or 'language'.
  • Uses: apply_filters() Calls 'language_attributes' on output just before sending it to browser.

Changelog

Since: 2.1.0

Source File

language_attributes() is located in wp-includes/general-template.php.

Related

See also index of Function Reference and index of Template Tags.