Van Gogh and Gauguin visited the city of Montpellier in December 1888.
A style attribute on an <i> tag assigns a unique style to the element.
Its value is CSS that defines the appearance of the i element.
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>
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.
<i style="CSS-styles">
Value | Description |
---|---|
CSS-styles | One or more CSS property/value pairs separated by semicolons (;). |
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>
The style attribute assigns a background color to the <i> element.
When clicking the button JavaScript changes the element background color.
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 |
Back to <i tag>