Set the text font. The face attribute of the font tag. Font control tags in HTML What tags set the font size

First of all, I want to digress a little from the topic and talk about my code examples, for example, in the previous chapter I did not depict the full page code anywhere, but only showed it like this:

  • HTML
  • CSS
    • introduction
    • types of documents
    • style types
  • PHP
But what I really meant was this: Using lists.
    photoshop
  • HTML
  • RNR
Those. in the future you should understand that all the tags that I demonstrate you must insert into the main HTML template between the tags And

Now let’s return to our chapter; to perform all these functions listed in the title, a container tag is used

Now let's get back to our topic.

In order to change the size, font or color of the text of a separate section in HTML, there is a container tag separate piece of text

Let's start in order and learn how to change the text color of a separate section, for this purpose in a tag FONT need to place attribute COLOR like this:

color="red"> separate piece of text Attribute values color the same as for the bgcolor text attributes of the body tag, i.e. we can specify them with words in English (Black, Green, Silver, Lime, Gray, Olive, White, Yellow, Maroon, Navy, Red, Blue, Purple, Teal , Fuchsia, Aqua) or color numbers in RGB (#000000- #FFFFFF)

face="Tahoma"> separate piece of text Fonts serve to make the text have a more extraordinary appearance, but there is one problem, the fonts that you have (you can view them in C:WINDOWSFonts) may not be available to your visitors, the second problem with fonts is that some fonts can only be used in Cyrillic (Russian letters) or vice versa only with the Latin alphabet (English letters), there is, of course, a third type that is suitable for both the Latin and Cyrillic alphabet. In the lower list I will show which fonts are standard and are available on all computers and also fit any letters:

  • Arial
  • Cosmic Sans
  • Courier
  • Garamond
  • Helvetica
  • Verdana
  • Tahoma
  • Times
  • Times New Roman
You can specify multiple fonts at the same time: face="Tahoma, Times, Verdana"> separate piece of text
From this code I would like to note the following: if your visitor does not have the font Tahoma, then the text will be provided in the font Times, and if there is no Times, then the text will be Times New Roman. Well, if this font is not there, then the default font of the browser.

Now let's move on to sizes, you can change the text size in HTML using two tags font and/or BASEFONT.
Let's start with BASEFONT, this tag is used to change the base color, font and size of the text, for example:
....text....
This tag is not a container, i.e. has no back tag. The color and font of the text are set as in the tag FONT, but to change the text size the attribute is used SIZE with a value from 1 to 7. This tag can be used several times in the text: size="4">....text....
size="6">....text....
size="3">....text....
By default, text size = "3", this size can not be specified. In the first example we increased the text by one, in the second line we increased it to “6”, and in the third we returned it to the default text again.
Now I want to disappoint you, this tag was introduced in version HTML-4.01, and accordingly, only Internet Explorer is supported in the browser, other browsers simply ignore it, So it’s better not to use this tag at all!!!
And use only the tag FONT with SIZE attribute it is supported by almost all browsers. SIZE attribute, also takes values ​​from 1 to 7, but these sizes can also be specified from “-2” to “+4”
text
text
text
text
text
text
text
The FONT tag, like BASEFONT, can contain several attributes:
size="5" color="red" fase="Tahoma, Times, Verdana">.... text....

Greetings to all readers of this article and subscribers of my blog! I want to devote today’s publication to a topic without knowledge of which your Internet resources will not be readable and attractive: “How to set a font in HTML.” The topic itself is easy and I am sure you will master it quickly.

However, we should not forget that web languages ​​are rich in all sorts of font design tools that, ideally, you need to know. After reading the article, you will confidently master text formatting, learn how to set different styles, types of font styles and decorations, as well as change the size and color of both sentences and individual letters. Let's get started!

Fonts are different

The bulk of signs, press and literature, websites and other services use standard fonts. Although they are comfortable, they have long become boring and do not catch the eye. That is why many designers slightly change the type of design or create new styles altogether. The most famous and influential fonts are:

  • Helvetica;
  • Futura;
  • Garamond;
  • Bodoni;
  • Bembo;
  • Rockwell;
  • Times New Roman.

Their main differences lie in their relationship to certain families. There are serif (serif), sans serif, decorative, italic, and monospace families.

I also want to emphasize that there are 5 font sizes.

Let's start with the html language and its “creative abilities”

Formatting text using html tags

Name first header

P subtitle with a red letter!

Here is located first paragraph current example. For clarity these words will be written in italics.

Let me remind you that the attribute align = "center" sets the text to be displayed in the center.

And now the time has come for css to show off its skills

Despite the whole set of various tags provided by html, css is a more convenient and flexible tool for designing the appearance of fonts.

The main properties used to format content are: font and its components: text-decoration.

Let's look at it first font. This is a universal parameter, thanks to which you can set several values ​​at the same time. In addition, each parameter operates with its own keywords.

Property name Keywords
font-family Can be installed as standard font families:

· without serif (sans-serif);

· antique (serif);

· decorative (fantasy);

· italic (cursive);

· monospace (monospace),

So are the standard existing styles (Arial, Calibri, etc.).

font-size To set the absolute size of symbols, the following notations are used: xx-small, x-small, small, medium, large, x-large, xx-large. You can also specify a unique value.
font-weight Responsible for the saturation of text style. Changes in range or is specified using the words normal, bold, lighter or bolder.
font-variant Specifies the representation of letters using the keywords: small-caps, normal, or inherit.
font-style Sets normal, oblique, italic, or inherits parent.
font-stretch Indicates the density of letters. The following values ​​can be specified: ultra-condensed, ultra-expanded, extra-condensed, extra-expanded, semi-condensed, semi-expanded, normal, expanded, condensed and inherit.

Property text-decoration helps to decorate text with additional elements such as underlining ( underline), strikethrough ( line-through), overline ( overline), and also inherit the parameters of the parent ( inherit) or cancel all registration ( none).

Now it's time for the second example. I took the previous code and styled it using css. So, the title was decorated with a shadow (using the property text-shadow) and with an outline around ( border-color). At the same time, I made one word larger. I also wanted to use the parameter opacity to set the transparency of the subtitle.

Formatting text using css properties

Name first header

Translucent subtitle!

Here is located first paragraph current example. For clarity these words will be written in italics.

Description

Tag increases the font size by one compared to normal text. In HTML, font size is measured in arbitrary units from 1 to 7, the average default text size is 3. Thus, adding a tag increases the text by one conventional unit. Nested tags are allowed , and the font size will be larger with each level.

Font size is affected not only by the specified size attribute of the tag , but also the choice of font typeface. The Arial font appears larger than the Times font, and the Verdana font is slightly larger than the Arial font. Take this feature into account when choosing a font and its size. For more precise control of text size, use styles.

Syntax

Text

Closing tag

Required.

Attributes

Similar to CSS

HTML 4.01 IE Cr Op Sa Fx

Tag BIG

Lorem ipsum dolor sit amet

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 below.

In addition to using standard font sizes and styles (typefaces), you can define fonts for each text fragment using special tags. The easiest way is to use the so-called physical styles:

For each physical style tag, there is a corresponding closing tag that disables further application of the style. For example, for the tag the closing tag is.
Below is an example program and the appearance of different physical styles:


<НЕАD><ТIТLЕ>Physical styles

<В>Bold
Italics
Stressed
Crossed out
<ТТ>Typewriter
<ВХ1>Bold italic
<ВХ1><и>Bold italic underlined


Rice. 649. Physical styles

You can insert a physical style tag inside a title tag to modify the entire title or just a portion of it. For example, to italicize part of the text defined as a heading, you can use the following construction:


<НЕАD><ТIТLЕ>Physical and Logical Styles

<Н2>This - modified 2nd level header

Rice. 650. Changing the font style of part of the title

Using a special tag You can customize the font for text images: set the typeface, size and color. First of all, you can set the size of the main font that is used in the document by default. the main font tag has the format . The main font size can be set from 1 to 7. If you do not use this tag, the default main font size is set to 3.
tag sets the current font size for individual text fragments. This tag does not affect styles. The range of possible values ​​is from 1 to 7. This tag also allows you to control the size of the current font relative to the main one. To do this, use the + symbol (to increase) and the - symbol (to decrease) the font size by a given amount. For example, if the body font size is set to 3, then the tag sets the current font size to 5.
To set the font typeface, use the tag . For example:

If this tag is not used in your document, then the browser will use the font set in its preference. Therefore, the text on the user's screen may look completely different from how you imagined it. You should also keep in mind that if the font you designate is not installed on the user's computer, the browser will display text in the default font.
You can in the tag indicate a list of fonts separated by commas. In this case, the browser will use the first font found. For example, you can write a tag:

FACE="Arial, Sans Serif, Courier">

Typically, similar fonts are specified in the list. It is recommended to assign the most popular fonts. When placing text information on a page, it is better not to assign a font name at all, relying on the standard browser settings. But then, when designing a page, you should also use standard browser settings to synchronize your perception of the text with the possible perception of the user. After all, you are creating a page not for yourself, but for your readers.
Using the COLOR attribute on a tag you can set the font color:

The COLOR attribute argument is a hexadecimal representation of the color code (red, green, and blue components, aka RGB components). The following program demonstrates font management:


<НЕАD><ТIТLЕ>Installing fonts

<Р>Aria font ABVGDEZZHIK
<Р>Courier font ABVGDEZZHIK
<Р>Font SYMBOL ABVGDEZZHIK


Rice. 651. Using different fonts

Note that in the tag you can use some or all of its possible attributes. For example:

In mathematical formulas, as well as for footnotes, indices are often used, which differ from the main text in position (slightly higher or lower) and size. Tags serve this purpose And respectively for upper and lower indices.


<НЕАD><Т1ТLЕ>Indexes/NEAD>

<НЗ>Example of using indexes
<Р>(5+x 2)x+3

a 1+a 2+a 3
<Р>Footnotes 2


Rice. 832. Using superscripts and subscripts

In addition to those discussed above, there are additional text formatting tags:

  • - selection of email addresses, postal addresses and
    telephone numbers;
  • <СIТЕ> - highlighting quotes;
  • , - recording program texts, symbolic constants;
  • - entering texts from the keyboard.

The last three styles use a monospaced font (usually Courier). For example, the letters I and Ж in a monospace font occupy the same space. The use of monospace fonts is due to the ease with which text can be aligned using space characters.
Let us note one more point. Font control tags, like logical style tags, can include the attribute TITLE= "string", which allows you to attach a tooltip to the text inside this tag. Attribute argument TITLE is the hint string. When you hover your mouse over a highlighted word or phrase, a tooltip will appear next to the pointer. Using this technique, you can decipher abbreviations and provide additional explanations and recommendations to the user.




The first thing you should pay attention to is text formatting in HTML, since on almost any page most of the information is presented in text form. In addition, by studying this topic, you will become familiar with a significant part of HTML tags.

The group of HTML tags designed to work with text can be divided into two main subgroups: physical formatting tags And logical text formatting tags.

Physical formatting tags physically affect the text - they are responsible for highlighting, placing, and formatting the text, which is necessary for its correct and uniform display in browsers.

Logical formatting tags are largely semantic, and some of them are primarily intended for the convenience of search engines.

Physical formatting tags include the following tags:

These tags belong to the logical formatting group:

Paragraph in HTML. Wrap text

The most important tag for physical text formatting is the tag

Which is designed to break text into paragraphs.

Each tag

Creates a new paragraph. In this case, the text begins on a new line, and a gap is formed between paragraphs.

Tag align attribute

Allows you to position a paragraph horizontally, placing it on the left (align="left"), on the right (align="right"), centered (align="center") or justified (align="justify" ) of the browser window or parent element.

Text after tag
also starts on a new line. But the tag
only breaks lines - it does not create a gap between them and can be used inside a tag

Tag on the contrary, it prohibits line wrapping. If the length of the line exceeds the width of the browser window, a horizontal scroll bar will appear. In turn, the tag allows line breaks within a tag .

"center" > The text is divided into paragraphs.


When viewed in a browser, a new paragraph is separated from the previous one by a blank line. Tag
used for line breaks.

The text is divided into paragraphs.

When viewed in a browser, a new paragraph is separated from the previous one by a blank line. Tag
used for line breaks.

Headings in HTML. Text size

Headings in HTML are represented by six tags

...

. Each of them denotes a heading of a certain level ( weight or significance).

Tag

highlight the most significant parts of the document ( topic of the page or article), and the text enclosed in it is the largest.

Tags

And

You can highlight subtopics, large sections - as a rule, there are few of them per page. The text in such headings is no longer as large as in top-level headings.

The use of headings in HTML “makes life easier” not only for users in terms of convenient and quick navigation on the page, but also simplifies the work of search robots, allowing them to highlight the main and the secondary, which has a positive effect on the optimization of site pages.

Tags

...

, like the tag

They have an align attribute that allows you to align the title horizontally.

Using a closing tag for all HTML headers is a must!

Level 1 header


Level 2 header


Level 3 header


Level 4 header


Level 5 Header

Level 6 Heading - Fine Print!

Level 1 header

Level 2 header

Level 3 header

Level 4 header

Level 5 Header
Level 6 Heading - Fine Print!

As you can see from the example, by converting a piece of text into a heading, we influence its size - we increase or decrease it depending on the level of the heading.

Text size continued...

Tags And also allow you to change the text size: they increase and decrease accordingly current size font per unit.

In HTML, font size is specified in conventional units from 1 to 7. By default, the text has a medium font size, referring to the 3rd conventional unit.

Tags And are designed to display text as superscript and subscript, respectively. In this case, the font size is reduced by one.

And finally let's look at the tag . It is intended not only to change the size of the text, but also to set its characteristics such as color and specifying the font family.

Tag size attribute sets the font size in arbitrary units from 1 to 7, the color attribute is intended to set the color ( Color can be set in two ways), and the face attribute specifies the font family.

Increase And decrease current font size by one conventional unit.

Index upper....... and Index lower....... in HTML.

Let's change the characteristics of the current font "Arial, Helvetica, sans-serif"> using the font tag

Increase or decrease the current font size by one unit.

Superscript...... and Subscript....... in HTML.

Let's change the characteristics of the current font using the font tag

Tag is intended to set the same text properties as the tag . The difference is that the tag can be located both in the body and in the head of the document. In doing so, it defines the text properties for the entire document, with the exception of the text located in the tag .

Tag Only supported by Internet Explorer. Its use is not recommended. However, it is not recommended to use the tag !

Learn CSS and work with styles!

Font typeface

In terms of style, the font may differ in setting - upright or italic, and in weight ( density) - light and bold.

By default, you see light direct text in the browser. Tag allows you to display text in italics, and the tag make it bold.

Let's change the font style: its production And saturation!

Let's change the font style: its production And saturation!

Monospace font

Many development environments and source code editors are configured to use monospace fonts by default. This is done for the convenience of programmers: the readability of the code is improved.

The fonts of this family are distinguished by the fact that all letters have the same width.

In HTML, several tags display text in a monospaced font.

One of them is the physical text formatting tag

In addition, displays the text in the browser with all spaces between words ( by default, browsers treat multiple spaces following each other as one).

The remaining HTML tags that display text in a monospaced font are logical text formatting tags. Their other purpose is that they provide various types of information for search engines and other programs about the text contained in them:

Tag - displays text that is program code;

Tag - denotes the text that is typed on the keyboard or for the names of keys;

Tag - designed to display text that is the result produced by a program or script.

Program code: FOR i=1 TO 20


Key names: Alt+F1


Script result: Hello PHP!


All spaces between words:

One Two Three - Try it yourself!

Program code: FOR i=1 TO 20

Key names: Alt+F1

Script result: Hello, PHP!

All spaces between words:

One Two Three - Try it yourself!

Quotes in HTML. Underlining and striking out text

Tag is intended to underline text, and the tag to cross it out. These are tags for the physical formatting of text, and, apart from visual design, they do not carry any semantic load.

In what cases you will use these tags is up to you!

Stressed And crossed out text - That's it!

Stressed and crossed out text - That's it!

Quote formatting

Perhaps, during the process of creating a site, you will need to insert a quote onto the page.

A quotation is a verbatim excerpt of text from a work. It is desirable that the quoted text be identified by the reader as inserted. To do this, the quote must be highlighted/formatted accordingly.

In HTML there is a special tag for this purpose -

. The text enclosed in this tag is formatted as follows: there are spaces above and below the main text, and indents to the left and right ( approximately 40 pixels).

As G. Lamene said:

Science serves only to give us an idea of ​​the extent of our ignorance.

As G. Lamene said:

Science serves only to give us an idea of ​​the extent of our ignorance.

Multiple boolean tags

We have not touched on 3 more tags that belong to the logical formatting group: these are tags , And .

Tags And similar. The first one is intended to indicate an abbreviation, the second one is an acronym.

An acronym is the same as an abbreviation, only it is pronounced as a single word, and not letter by letter.

Both abbreviations, when viewed in a browser, are underlined with a dotted line, and it is advisable to add a tooltip to both - a decoding of the abbreviation ( using the title attribute).

Tag used to enclose text in quotation marks. This tag can be used when formatting quotes or when using words and expressions that have a figurative meaning.

HTML- this is an abbreviation - pronounced letter by letter.


"Research Institute"> research institute is an acronym. The acronym is used as an independent word.


Twins look alike The same .

HTML is an acronym - pronounced letter by letter.

Research Institute is an acronym. The acronym is used as an independent word.

Twins are like two peas in a pod.

Share with friends or save for yourself:

Loading...