How to make a beautiful font in html: sizes, colors, html font tags. Basic HTML text formatting tags - highlighting text in bold and italics; size, color and font options; paragraph and heading tags Html italic font

💖 Do you like it? Share the link with your friends

Html gives us some options in terms of text design. Today I will tell you how to make an italic font in HTML, both in a standard font and in a non-standard one. In the second case, you will need to take a few things into account to make everything work.

How to write italics in html?

Let me start with the fact that in the html itself there are two tags that give the text an italic style. These are em and i. By the way, the second one is built into the html editor of the WordPress engine, in which I am currently writing this article. How are these tags different? In fact, today I would not like to loudly declare that they are somehow different.

In general, em is supposed to be used to highlight words that need to be pronounced with a special intonation, and i simply visually highlights the text. But let’s not worry about it, because we don’t know if this is actually the case.

What are the CSS properties for italic text?

This is the font-style property and its value is italic. There is also the value oblique and it turns the text into italic. Is there any difference between these values? Virtually none. By the way, details about this and others css properties for the text, read the corresponding article, where everything is sorted out.

How to display a non-standard font in italics?

The fact is that if you connect a non-standard font via Google Fonts, then in this case you must check the box when connecting at least 1 italic font style. If this is not done, then when you try to make such a font italic, italics of one of the standard fonts will be displayed. By the way, you can read about connecting non-standard fonts in this article.

In this screenshot you can see a fragment of the font connection via Google service Fonts.

As you can see, there is a checkmark next to at least one italic style. Now, when using the necessary tags or style properties, this font will indeed become italic, and not some other.

Thus, we have discussed all the points that exist in working with italics. I don't dare detain you any longer.

One of the easiest ways to highlight a word or phrase in text is to use a different letter style. This is how you can emphasize a word or phrase using bold. Pages easily allow you to highlight words using different styles - italic, underlined, bold.

Bold font as a way to highlight the main thing

Words highlighted in bold font look brightest and catchiest. Such words and phrases immediately catch the eye. So, in order to learn how to quickly highlight the necessary places in the text, you should remember a special HTML code. Bold font is set using a paired tag.

Before the word or phrase or sentence that should be highlighted, an opening tag is placed . After the last letter of the text that should be highlighted, a closing tag is placed. Anything between these two tags will appear in bold when displayed in the browser.

Other highlighting options

So, we found out that you can highlight text using a different style. We decided that it is easiest and at the same time effective to use bold HTML font. Now let's talk about other selection options.

So, you can highlight text in italics using a paired tag , emphasize it with . This is the most simple ways highlighting text.

There are also lesser known and used tags that can be used to highlight words and sentences in text. So, in order to cross out the text, it is enough to use . A paired tag will help make text monospaced . If you need to create a superscript, use , lower - .

In this case, as before, the text you need should be between the opening and closing tags. As you can see, there is nothing complicated, the main thing is to remember these codes or write them down.

Using multiple fonts

If you want to make your text more expressive, you can use more than just bold fonts. HTML markup allows you to highlight a word using multiple styles at the same time. So, you can make a word bold, strikethrough, and italic at the same time.

At the same time, you need to remember one thing - all tags must be closed sequentially. For example, a correct entry might be:

  • the selected text.

If you close the tags in a different order, the text will be highlighted incorrectly. An example of an erroneous entry:

  • the selected text.

In this case, the browser will get confused and will not understand what exactly you want from it.

By the way, it can be noted here that the three style options - bold, underlined and italic - are remembered quite easily if you know the hot keys in Word. There, the style is set using the same letter keys while holding Ctrl.

As you can see, you can use not only italic or bold fonts. HTML markup allows you to highlight words as easily as regular Word.

conclusions

To highlight text, not only various colors and shades, different sizes and types of fonts, but also its style are widely used. Moreover, it is with the help of a different outline that one or another fragment of text can be beautifully and easily highlighted.

To change the font style, you should use any tag you know. The bold font of an HTML page is the brightest and most noticeable font, and therefore is most often used for emphasis.

To make our WEB page look more presentable, we will divide the text into paragraphs and highlight the title. HTML has 6 levels of document section headings, numbered 1 to 6. Headings are declared by a pair of tags with numbers corresponding to the level, for example,

- the title of the first level section, and
- the title of the sixth level section. Titles differ from regular text in the size and width of the letters. The first level heading h1 is usually displayed in a very large font, while the sixth level heading h6 is usually displayed in a very small font.

Titles

Do not confuse document section titles with the previously discussed document title, defined by the element .

We use the first sentence as the title of the text - To do this, it’s enough to limit it with tags

And

.

Insert tags into the text of the other.html file

And

so that they limit the first sentence of the text, and this piece of code takes the following form:

Welcome to the SD company page!

Let's look at the acquired result.

Save the file by selecting the Notepad menu command File - Save.

The saving operation must always be done before viewing the document, because it opens the file for viewing by loading it into the computer’s RAM from disk. If you do not save the file after editing the HTML code, you will not see any configurations in the browser.

Restore the browser window by clicking its button on the Taskbar.

Press the F5 button or the Refresh button on the toolbar of the program's working window. The other.html file will be reloaded and you will see what the first level header looks like in your browser window.

See how the titles of the other 5 levels will look by changing the numbers in the tags: h2, h3, and so on. After each configuration, do not forget to save the file and update the image in the browser window.

When you finish the experiments, restore the tags in the other.html file again

.

Using the 6 levels of headings that HTML provides, you can create an easy-to-read document with an intuitive structure. Remember that your document will always be much better read if it is clearly divided into sections and subsections.

Heading Alignment

By default, the title is aligned to the left edge of the page. But it can also be aligned to the right or centered. For right alignment in a tag

The attribute align="right" is used, and for centering - align="center". An obvious indication of left-side alignment is also allowed - align="left".

Add to tag

align="center" attribute to center the title. This element should look like this:

Welcome to the SD company page!

In the future, we will not remind you of the need to save the file with the initial code and refresh the image in the browser before viewing.

How to make text highlighted (bold) in HTML

Now let's move on to the rest of the text. Let's increase its size and make the text bold italic. To set bold style, paired tags are used .

Insert the opening one in the other.html file and closing tags so that they limit the text. Here you will find out... This element should take the following form:

How to make text italic in HTML

Italic style is set using tags .

Insert an HTML tag into the initial code And so that the edited element takes the following form:

Here you will learn about our activities, about the software products of our company and about the equipment that we produce

Markup elements can be nested, as in this structure, where the element nested within an element . Modern browsers are able to correctly handle nested tags. Therefore, you need to ensure that the order of investment is not violated. The browser will be difficult to operate if the nesting is broken. For example, this entry would be incorrect: . Compliance with nesting is a very important part of the general culture of writing HTML code.

How to make text underlined in HTML

Using a couple of tags you can set the underlined style of a text piece limited by these tags, and using a pair of tags - show text in teletype font.

It should be noted that recently the tag simplified and emphasized using styles. equivalent . Yes, the new analogue looks more cumbersome, but unfortunately this is more true. The main thing in favor of this is that the bulky version is cross-browser, in other words, suitable for all browsers, when Not all browsers support it.

How to increment text in HTML

Now let's increase the text font size. This can be done using various methods.

Tags increase the font size of the text enclosed between them.

Add tags to the beginning and end of the above piece of code, respectively And so that the element takes the following form:

Here you will learn about our activities, about the software products of our company and about the equipment that we produce

Using tags you can reduce the text font size compared to the initial one.

Another method of specifying font size is using tags with the size attribute. Integers from 1 to 7 are used as values ​​for this attribute. In this case, value 1 corresponds to the smallest font size, and value 7 corresponds to the largest.

Using instead of tags view tags , see how the text font size changes for different values ​​of the size attribute - from 1 to 7.

You can also use numbers from 1 to 7 with a + (plus) or - (minus) sign as the value of the size attribute. In this case, the font size increases or decreases accordingly, compared to the initial one, for example, tags The font size will increase by one level compared to the current one. Check it out.

Set 5 as the value of the size attribute for the piece of text in question: . The HTML code for this piece should be like this:

Here you will learn about our activities, about the software products of our company and about the equipment that we produce.

In tags The color attribute can also be used to specify the color of the font limited by text tags. The meanings of this attribute are the same as for the previously discussed attributes that describe the color of the background and text of the document.

By default, the paragraph with the text Here you will find out... is aligned to the left. Center it horizontally using tags

. You can also align a paragraph to the right edge of the page using tags or left - using tags .

Insert tags

limiting them to the designated paragraph.

Please note that we used tags to center the paragraph

, unlike the align="center" attribute that we used in tags

.

Attention! For 2010 tags ,

, , are considered obsolete and therefore it is necessary to use analogues from the styles. This does not mean that you cannot use them, but if you are able, try to get rid of them.

=

=

=

=

=

There are also a huge number of other outdated tags that cannot be outlined in this article, so it is better to immediately familiarize yourself with specialized WEB sites on this issue. But I posted the main ones here a little higher

Allocation codes

The HTML language allows two approaches to font selection of text fragments. On the one hand, you can directly indicate that the font on a certain section of the text can be bold or italic; in other words, you can clearly indicate the font style of the text, as we did in this experiment. On the other hand, you can mark any piece of text as having some logical style that is different from the usual one, leaving the interpretation of this style to the browser. Thus, the logical style shows the role of a text piece, for example, its enormous significance compared to in ordinary text or that this piece is a quotation. In your own work, you can use subsequent tags that define logical styles. Check how they work in different browsers.

- used to define a word. Text is displayed in italics by default.

- to highlight words and strengthen them. Text is displayed in italics by default.

- to highlight the titles of books, films, performances, and so on, it is displayed in italics by default.

- for program code fragments. Shown on the display in a fixed width font.

- used for text that the user enters from the keyboard. May appear in different fonts in different browsers. Tag is obsolete.

- serves to display program messages. Displayed in a fixed width font. Tag is obsolete.

- for particularly important fragments. Usually highlighted in bold.

- used to indicate that a piece of text or a word is a symbolic variable, in other words, text that can be replaced by different expressions. Displayed in italics by default. Tag is obsolete.

The HTML 4.0 specification offers a more advanced method of specifying styles for text and other parts - using a special language called CSS (Cascading Style Sheets). Style sheets are a huge achievement in the field of WEB design, expanding the ability to improve the appearance of pages. Style sheets make it easy to define line spacing, padding, colors used for text and background, font size and style, and so on. Most parts of HTML can be styled using a style attribute, which is placed inside an element's opening tag. Pairs of the form “property: value” are used as the value of the style attribute. For example, in a piece of code describing the section header,

the style="color: blue" attribute specifies that the color property has the value blue, in other words, the first level heading text should be displayed in blue.

Alignment with styles

Let's see how to use the Cascading Style Sheets language to specify the style of a text piece that begins with the words Here you will learn...

To specify the font thickness, use the font-weight property with the values ​​lighter (narrow), bold (semi-bold), bolder (bold), for example, style="font-weight: bold".

To determine the italic style, use the font-style property with the value italic. Therefore, to give the text a bold italic style, you should find the style attribute like this: style="font-weight: bold; font-style: italic". Please note: characteristics can be placed in any order and must be separated by a semicolon.

If you need to specify the font size, you should use the font-size property, the values ​​of which can be specified in relative or absolute values. Relative values ​​are percentages, and points (pt), pixels (px), centimeters (cm), millimeters (mm) are used as absolute values. Eg:

style="font-size: 200%"

style="font-size: 16pt"

style="font-size: 100px"

By specifying absolute rather than relative sizes, you deprive users viewing your pages of the ability to increase or decrease font size using the browser menu command in accordance with their vision and monitor resolution. Fonts will only be displayed in the size you specify. Therefore, it is better to specify the font size as a percentage. In this case, the font size will be smaller or larger by a specified percentage than when formatted using the default HTML tag.

To determine the horizontal text alignment method, use text-align property with the values ​​left (left), right (to the right), center (center), justify (width). Thus, to indicate that the text Here you will learn... should be formatted in bold italic style with a size of 150% of the original and aligned to the center, its style should be found as follows:

style="font-weight: bold; font-style: italic; font-size: 150%; text-align: center"

We will use this attribute in tags<р>, which allow you to present text as a separate paragraph.

Edit an HTML element that includes the text You'll learn here... by removing tags

, , , and inserting tags<р>Andwith the style attribute so that this element takes the following form:

<р style="font-weight: bold; font-style: italic; font-size: 150%; text-align: center">Here you will learn about our activities, about the software products of our company and about the equipment that we produce

You see, HTML allows for a variety of styling techniques. At the same time, the use of the cascading table language CSS styles is more desirable.

Other alignment and styling options

We've only seen one use case for stylesheet language, where the style definition is placed specifically within the tag of the element you're describing.

This is done using the style attribute, which is used with most standard HTML tags. But there are other uses for CSS.

In standard HTML, without introducing style sheets, in order to assign certain parameters to any element, such as color, size, position on the page, and the like, you have to outline these characteristics for each element every time, even if 10 pages must be placed on one page. ki of such parts that do not differ from one another. You have to insert the same piece of HTML code into a page tens of times, increasing the file size and the time it takes to download it from the Internet.

Style sheets work in a different, more comfortable and economical way. To assign certain characteristics to an element, you must outline this element once and find this description as a style, and then simply indicate that the element that you want to design appropriately must take on the characteristics of the style you described. Comfortable, isn't it?

Moreover, you can save the style description not in the text of your WEB page, but in a separate file - this will allow you to use the style description on any number of WEB pages. And another related advantage is the ability to change the design of any number of pages, correcting only the style description in one separate file.

In addition, the style sheet language allows you to work with the font design of pages at an even higher level than standard HTML.

Currently, the CSS language has a fairly large number of parameters for parts of HTML that it can control. By using “secure”, in other words compatible with the largest number of browsers CSS elements- font characteristics, colors of parts and background, characteristics of text and borders - you can significantly facilitate your work and make your WEB pages more attractive in terms of text design.

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

Tags and attributes when working with html fonts

Hypertext language has a wide range of tools for working with fonts. After all, text formatting is the main task of html.

Reason for creation HTML language There was a problem with browsers displaying text formatting rules.


Let's look at the tags that are used to work with fonts in HTML and their attributes. The main one is the tag . Using the values ​​of its attributes, you can set several characteristics of the font:

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

Positive attribute values ​​from 1 to 7 are supported.

  • face – used to set the text font family that will be used inside the tag . Several values ​​are supported, separated by commas.

Only the text located between the parts is formatted tag pair font. 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 similar in action to the previous one;
  • — the size is larger than the default;
  • — smaller font size;
  • — italic text (italics). Similar tag ;
  • — text with underlining;
  • - crossed out;
  • — display text only in lower case;
  • - in upper case.

Plain text

Thumbnail

Thumbnail

More than usual

Less than usual

Italics

Italics

With underscore

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 to use the generic style attribute. Using the values ​​of its properties, you can set the display style of fonts:

1) font-family – the property sets the font family. It is possible to list multiple values.
Changing the font in html to the next value will happen if the previous family is not set to operating system user.

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 | meaning | interest | inherit

You can also set the font size:

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

Font-size:7

Font-size:24px

Font-size: x-large

Font-size: 200%

Font-size:24pt

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

font-style: normal | italic | oblique | inherit

Values:

  • normal – normal spelling;
  • italic – italic;
  • oblique – font slanted to the right;
  • 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 capital letters to capital letters. 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 text (saturation). Syntax:

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

Values:

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

font-weight:bold

font-weight:bolder

font-weight:lighter

font-weight:normal

font-weight:900

font-weight:100

HTML font property and font color

Font is another container property. Inside itself, it combined the values ​​of several properties intended for changing fonts. font syntax:

font: font-size font-family | inherit

The value can also be set to the fonts used by the system in the labels on various controls:

  • 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

To set the font color in HTML, you can use the color property. It allows you to set the color using keyword, and in rgb format. And also in hexadecimal code.

Saturation is an increase in the thickness of font lines and, accordingly, contrast. There are usually four types of weight: light, normal, bold, and bold. However, with using HTML You can only set normal and bold style. To set bold text, two tags are used: And .

Bold font style Strong text highlighting

Italic style

Italic font is not just a slant of individual characters, for some fonts it is a complete redesign to a new style that imitates handwriting. Italics for text is determined by two tags: And .

Italic font style Text selection

It should be noted that tags And , as well as And although similar in their effect, they are not entirely equivalent and interchangeable. First tag - is a physical markup tag and sets the bold style of the text, and the tag - with a logical markup tag and highlights the marked text. This division of tags into logical and physical formatting was originally intended to make HTML universal, including independent of the output device. Theoretically, if you use, for example, a speech browser, then text formatted using tags And , will be marked differently. However, it turned out that in popular browsers the result of using these tags is equivalent.

Example 7.5 shows the use of tags And for formatting texts.

Example 7.5. Tags And

Text decoration

Where are the cookies and moonshine?! - exclaimed the Bad Boy.



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



tell friends