--- title: String.prototype.italics() slug: Web/JavaScript/Reference/Global_Objects/String/italics translation_of: Web/JavaScript/Reference/Global_Objects/String/italics ---
{{JSRef}} {{deprecated_header}}

The italics() method creates an {{HTMLElement("i")}} HTML element that causes a string to be italic.

Syntax

str.italics()

Description

The italics() method embeds a string in an <i> tag: "<i>str</i>".

Examples

Using italics()

The following example uses string methods to change the formatting of a string:

var worldString = 'Hello, world'; console.log(worldString.blink());  // Hello, world
console.log(worldString.bold());  // Hello, world
console.log(worldString.italics()); //Hello, world
console.log(worldString.strike());  // Hello, world

Specifications

Specification Status Comment
{{SpecName('ES6', '#sec-string.prototype.italics', 'String.prototype.italics')}} {{Spec2('ES6')}} Initial definition. Implemented in JavaScript 1.0. Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.
{{SpecName('ESDraft', '#sec-string.prototype.italics', 'String.prototype.italics')}} {{Spec2('ESDraft')}} Defined in the (normative) Annex B for Additional ECMAScript Features for Web Browsers.

浏览器兼容性

{{Compat}}

See also