Italic text in HTML can be achieved using the <i> tag. The <i> tag is one of the original ways to format text and more recently CSS and other tags have reduced the importance of this tag. It is still a good tag when used correctly. When text is put between the opening and closing <i> tag it is displayed as italic text. The <i> tag can be used multiple times on a webpage and can be nested inside other tags for dramatic effect. Care should be taken when using this tag as italic text can be hard to read, especially at small text sizes.
<i>Some italic text</i>
Any text between the opening and closing tag will be displayed as a large heading.
It is possible to style and add functionality to the <i> tag, this is done by adding an attribute to after the i in the opening <i> tag
Attributes allowed for the <i>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<i id=”header”>Some italic text</i>
With all attributes there is a space after the initial b then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <i> tag the class attribute is nearly always used over the id attribute although in practice it makes no difference.
The attribute style allows you to include CSS style information for a single <i> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
<i>Some italic text</i> – basic usage example.
<i id=”header”>Some italic text</i> – italic text which is styled by the id header.
<i class=”header”> Some italic text </i> – italic text which is styled by the class header.
<i id =”header” class=”header”> Some italic text </i> – italic text which is styled by the class header and the id header.
<i style=”color:#F00;”>Some italic text</i> – italic text which has a custom colour of red.
<i dir=”rtl”>Some italic text</i> – italic text where the text reads from right to left.
<i lang=”uk”>Some italic text</i> – italic text where the language has been tagged as UK.
<i title=”title”>Some italic text</i> – italic text where the tag has been titled title.
Touching on just the surface of the <i> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.