style / title / lang
The style, title, and lang attributes are global attributes that can be specified on almost all HTML elements. Use style to apply inline CSS, title to display a tooltip, and lang to specify the language of the text within an element.
Syntax
<!-- Applying inline styles --> <p style="color: red; font-size: 1.2rem;">Red text.</p> <!-- Specifying a tooltip --> <abbr title="HyperText Markup Language">HTML</abbr> <!-- Specifying a language --> <p lang="en">This paragraph is written in English.</p>
Attribute list
| Attribute | Description |
|---|---|
| style | Applies inline CSS styles to an element. Write CSS properties separated by semicolons. |
| title | Specifies a title or additional information for an element. Most browsers display this as a tooltip on mouseover. |
| lang | Specifies the language of the text within an element. Uses BCP 47 language codes (e.g., ja, en, zh). |
Sample code
<!-- Applying inline CSS with style --> <p style="color: #e74c3c; font-weight: bold;">Important notice</p> <!-- Displaying a tooltip with title --> <p> For abbreviations, use the <abbr title="HyperText Markup Language">HTML</abbr> element with the <code title="Short for abbreviation">abbr</code> tag and the title attribute. </p> <!-- Specifying the language for each paragraph --> <p lang="en">日本語のテキストです。</p> <p lang="en">This is English text.</p> <!-- The title attribute on img works as a tooltip --> <img src="photo.jpg" alt="風景写真" title="北海道の雪景色(2024年1月撮影)">
Result
A paragraph with style applied is displayed in bold red text. Hovering over an element with a title attribute shows the specified text as a tooltip. The lang attribute communicates language information to browsers and screen readers but does not affect the visual appearance.
Notes
The style attribute is convenient for quickly testing styles or dynamically changing styles with JavaScript, but writing styles directly in HTML as inline styles reduces maintainability. It is generally recommended to use an external CSS file or a style tag instead.
The title attribute can be specified on any element, but it is mainly used to expand abbreviations (<abbr>) or to provide supplementary descriptions for links. Since tooltips are not displayed on touch devices such as smartphones, avoid relying solely on title for important information — include it in the body text as well.
The lang attribute is typically written on the <html> tag to specify the language for the entire page, but it can also be applied to individual elements when multiple languages are mixed within a page. Screen readers use the lang attribute to read content in the correct language, making it an important attribute for accessibility.
Browser Support
14 or earlier ×
Android Browser
37+ ○
4 or earlier ×
Chrome Android
36+ ○
17 or earlier ×
Firefox Android
79+ ○
3 or earlier ×If you find any errors or copyright issues, please contact us.