--- title: String.prototype.italics() slug: Web/JavaScript/Reference/Global_Objects/String/italics translation_of: Web/JavaScript/Reference/Global_Objects/String/italics ---
The italics()
method creates an {{HTMLElement("i")}} HTML element that causes a string to be italic.
str.italics()
The italics()
method embeds a string in an <i>
tag: "<i>str</i>"
.
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
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. |