CSS italics: change the font style. HTML5: Old Tags New Assignment Which Tag Italicizes

In this article, we will talk about how to select text. in italics HTML. As with bold text, italicized text can be made in three ways:

  • Tag i HTML;
  • Tag em HTML;
  • CSS property font-style.

Let's consider all three options for how you can make italic in HTML, discuss the subtleties of this issue and what methods are more convenient and more correct to use in certain situations.

Italic text: tag

Tag i (italic), similar to the tag b for bold text, it is used to physically highlight italic text (this means that only the style of the text changes). Tag application i:

Website builder "Nubex"

Thus, the required part of the text is placed between the tags .

Italic text: tag

Although the tag i remains valid, from the point of view of site optimization it is better to use the tag em to highlight logically important sections of text. This means that search engine spiders take into account the importance of the text placed between tags. :

Website builder "Nubex"

Result:

Website builder "Nubex"

But do not forget that the text enclosed in tags i and em, although they are displayed almost the same (in all modern browsers), in their essence they are not quite identical, as noted above. Therefore, you need to use tags as needed: tag em HTML to frame important sections of text, and apply visual italic design using a tag i or CSS styles. Now let's look at using CSS styles for italic text selection.

Italic text powered by CSS

To set styles for displaying fonts in CSS, use the property font-style, which can take on the following values: oblique (italic text), italic (italics) and normal (regular font).

It is worth remembering that italic font and inclined, in their essence, are not the same. Italics is a special font that is analogous to handwritten text, and inclined formed by tilting the regular font to the right.

Attribute application font-style on practice:

Italic with CSS - "Nubex"

Our sites are, indeed, huge step in web development.

We do for real quality sites.

But it must be remembered that some browsers text with the property font-style: oblique; may not be interpreted as italic text, but as italic.

Description

Specifies the style of the font - regular, italic, or italic. When text is set to italic or italic, the browser consults the system to find a suitable font. If the specified font is not found, the browser uses a special algorithm to simulate the desired type of text. The result and quality may not be satisfactory, especially when printing a document.

Syntax

font-style: normal | italic | oblique | inherit

The values

normal Normal text style. italic Italic style. oblique Italic style. Italic and italic, though similar, are not the same thing. Italic is a special typeface that imitates handwriting, while oblique is formed by tilting ordinary characters to the right. inherit Inherits the parent's value.

HTML5 CSS2.1 IE Cr Op Sa Fx

font-style

Duis te feugifacilisi

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat. Ut wisis enim ad minim veniam, quis nostrud exerci tution ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

The result of this example is shown in Fig. 1.

Figure: 1. Applying the font-style property

Object Model

document.getElementById ("elementID") .style.fontStyle

Browsers

Internet Explorer 7.0 or later does not support the inherit value.

Browsers always render text oblique as italic.

In html, font size plays an important role. It allows you to draw the user's attention to important information posted on the website page. Although not only the size of the letters is important, but also their color, thickness and even family.

Tags and attributes when robot with html fonts

The hypertext language has a large set of tools for working with fonts. After all, it is text formatting that is the main task of html.

The reason for the creation of the HTML language was the problem of displaying text formatting rules in browsers.


Consider the tags that are used to work with fonts in html and their attributes. The main one is the tag ... Using the values \u200b\u200bof its attributes, you can set several characteristics of the font:

  • color - sets the color of the text;
  • size - font size in conventional units.

Positive attribute values \u200b\u200bfrom 1 to 7 are supported.

  • face - used to set the font family of the text to be used inside the tag ... Several values \u200b\u200bare supported at once, separated by commas.

Only the text between the parts of the paired font tag is formatted. The rest of the text is displayed in the standard default font.

Also in html there are a number of paired tags that specify only one formatting rule. These include:

  • - sets bold font in html. Tag the action is similar to the previous one;
  • - the size is larger than the default;
  • - smaller font size;
  • - italicized text. Similar tag ;
  • - underlined text;
  • - crossed out;
  • - display text only in lower case;
  • - in upper case.

Plain text

Thumbnail

Thumbnail

More than usual

Less than usual

Italics

Italics

Underlined

Crossed out

Style attribute capabilities

In addition to the described tags, there are several more ways to change the font in html. One of them is using the generic style attribute. Using the values \u200b\u200bof its properties, you can set the font display style:

1) font-family - property sets the font family. Enumeration of several values \u200b\u200bis possible.
Changing the font in html to the next value will happen if the previous family is not installed on the user's operating system.

Writing syntax:

font-family: font name [, font name [, ...]]

2) font-size - the size is set from 1 to 7. This is one of the main ways you can increase the font in html.
Writing syntax:

font-size: absolute size | relative size | value | interest | inherit

You can also set the font size:

  • In pixels;
  • In absolute value ( xx-small, x-small, small, medium, large);
  • In percents;
  • In points (pt).

Font-size: 7

Font-size: 24px

Font-size: x-large

Font-size: 200%

Font-size: 24pt

3) font-style - sets the style of writing the font. Syntax:

font-style: normal | italic | oblique | inherit

Values:

  • normal - normal spelling;
  • italic - italic;
  • oblique - right-leaning font;
  • inherit - inherits the spelling of the parent element.

An example of how to change the font in html using this property:

font-style: inherit

font-style: italic

font-style: normal

font-style: oblique

4) font-variant - converts all uppercase letters to uppercase. Syntax:

font-variant: normal | small-caps | inherit

An example of how to change the font in html with this property:

font-variant: inherit

font-variant: normal

font-variant: small-caps

5) font-weight - allows you to set the thickness of the writing of the text (saturation). Syntax:

font-weight: bold | bolder | lighter | normal | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

Values:

  • bold - sets the html bold font;
  • bolder - fatter relative to normal;
  • lighter - less saturated relative to normal;
  • normal - normal spelling;
  • 100-900 - sets the font thickness in numeric equivalent.

font-weight: bold

font-weight: bolder

font-weight: lighter

font-weight: normal

font-weight: 900

font-weight: 100

The font property and html font color

Font is another container property. Internally, it combined the values \u200b\u200bof several properties designed to change fonts. The font syntax is:

font: font-size font-family | inherit

Also, fonts used by the system in inscriptions on various controls can be set as a value:

  • caption - for buttons;
  • icon - for icons;
  • menu - menu;
  • message-box - for dialog boxes;
  • small-caption - for small controls
  • status-bar - status bar font.

font: icon

font: caption

font: menu

font: message-box

small-caption

font: status-bar

font: italic 50px bold "Times New Roman", Times, serif

In order to set the font color in html, you can use the color property. It allows you to set the color using both a keyword and rgb format. And also in the form of a hexadecimal code.

Now we are going to study the main tags. Let's start with what tags are required on the page, forming its structure.

Block. The structure of the simplest page

A site page is a plain text file with the extension .html... This file contains the text of the HTML page along with the tags. This file must have the following tags: tag , which should contain the text of the entire site (everything written outside this tag will be ignored by the browser), and inside it there should be two more tags: tag for the service content of the page and the tag - for the main text, which is visible on the browser screen.

To service content that is located inside the tag , many different things come in, but for now we only need two of them. This is a tag , which sets the name of the page, which will be visible in the browser tab, and the tag <meta> , which sets the page encoding (it is set in the attribute <b>charset</b> and usually matters <b>utf-8</b>, more on this in the video, which will be a couple of paragraphs below).</p> <p>Also, before the tag <html> the construction is usually written <b>doctype</b>, which indicates the HTML version of the site. The current version of the language is number five and the doctype for it should look like this -<!DOCTYPE html> .</p> <p>So let's take a look at the basic structure of the page (to run this example in a browser, copy it into a text file with the extension <b>.html</b> and open in a browser if you have problems with this - watch the video below the example):</p> <p> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>This is the title title This is the main content of the page.

See this link for how this example looks in a browser.

I think after you read about the basic structure of the page, you still have some confusion about how it all looks in practice. Therefore, I made a special video in which I will show you how to make your first HTML page and run it in a browser (in it I will also tell you about the page title, about encodings, about code design). Take a look at it and only then move on to further reading:

Well, now that we have learned how to create the simplest pages, we will move on to exploring useful tags that should be used inside a tag ... These will be tags for paragraphs, headings, lists, links and other useful things. So let's get started.

Block. Paragraphs

One of the main elements of the page are paragraphs... They can be compared to paragraphs in a book - each paragraph starts on a new line and has a so-called red line (this is when the first line of the text of the paragraph is slightly indented to the right). There is no red line by default, but it is easy to do (more on that later).

A paragraph is created using the tag

Thus:

This is the title title

This is a paragraph.

This is another paragraph.

And one more paragraph.

This is a paragraph.

This is another paragraph.

And one more paragraph.

Block. Headings h1, h2, h3, h4, h5, h6

In addition to paragraphs, are important on the page headlines... They can also be compared to titles from a book - each chapter has its own title (the title of this chapter) and is divided into paragraphs, which also have their own titles. Well, and the main text of the page is in paragraphs.

Headers are created using tags

,

,

,

,

,
... They have varying degrees of importance. In the title h1 should have the title of the entire HTML page, in h2 - name blocks pages in h3 - the name of the subblocks, and so on.

All headings are bold by default and have different sizes (this can be changed through CSS, but more on that later). See example:

This is the title title

H1 heading

H2 heading

H3 heading

H4 heading

H5 heading
H6 heading

This is the first paragraph.

This is the second paragraph.

This is the third paragraph.

This is how the code will look in the browser:

H1 heading

H2 heading

H3 heading

H4 heading

H5 heading
H6 heading

This is the first paragraph.

This is the second paragraph.

This is the third paragraph.

Block. Fatty

You already know that the default headers are fatty... However, you can also make plain text bold - just take it into the tag ... See example:

This is the title title

This is plain text, and this is fatty text.

This is how the code will look in the browser:

This is plain text, and this is fatty text.

should be used inside some other tag, such as a paragraph. In this case, paragraphs create the overall structure of the page (paragraphs and headings), and the tag b makes individual pieces of text bold.

Block. Italics

In addition to fatty, you can also make italics using the tag :

This is the title title

This is plain text, and this is italic text.

This is how the code will look in the browser:

Block. Lists

Along with paragraphs and headings, there is another important element of the page - this is the lists... Such elements are probably familiar to all Internet users. They are a listing of something (a list) point by point. There is usually a filled circle next to each item on the list (it is called marker list).

Lists are created using the tag