HTML <i> style Attribute

The style attribute on an <i> tag assigns a unique style to the idiomatic text element. A style contains one or more CSS property/value pairs that define the appearance of the i element.

Example

#

An <i> element with a style attribute.

Van Gogh and Gauguin visited the city of Montpellier in December 1888.

<article>
  <p>
     Van Gogh and Gauguin visited the city of 
     <i style="background:papayawhip;color:brown;">Montpellier</i> 
     in December 1888.
  </p>
</article>

Using style

The style attribute defines the style (i.e. look and feel) of the <i> element.

It contains any number of CSS property/value pairs, separated by semicolons (;).

The style attribute overrides any other style that was defined in a <style> tag or an external CSS file.

This inline styling affects the current <i> element only.


Syntax

<i style="CSS-styles">

Values

#

Value Description
CSS-styles One or more CSS property/value pairs separated by semicolons (;).

More Examples

An <i> element with a style attribute.
Clicking the button toggles the background color.

Van Gogh and Gauguin visited the city of Montpellier in December 1888.


<article>
  <p>
    Van Gogh and Gauguin visited the city of
    <i id="myi" style="background:papayawhip;color:brown;">Montpellier</i> 
    in December 1888.
  </p>
</article>

<br/>
<button type="button" onclick="toggle();">Toggle style</button>

<script>
  let toggle = () => {
    let element = document.getElementById("myi");

    if (element.style.backgroundColor === "papayawhip") {
       element.style.backgroundColor = "cornsilk";
    } else {
       element.style.backgroundColor = "papayawhip";
    }
  }
</script>

Code explanation

The style attribute assigns a background color to the <i> element.

When clicking the button JavaScript changes the element background color.


Browser support

Here is when style support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <i tag>
Guides