Allows you to change the case of text letters.

The default value is none , which has no effect on the text. The case of the text remains the same. The values ​​uppercase and lowercase convert characters to uppercase and lowercase, respectively. If you specify capitalize , then only the first characters of each word will be capitalized. Inherit inherits the parent's value.

Example

h3 ( text-transform: uppercase; ) .lowercase ( text-transform: lowercase; ) .capitalize ( text-transform: capitalize; ) text-transform

This is the title. It has a text-transform property applied with a value of uppercase. All characters will be uppercase.

This paragraph has the Text-transform Property set to Lowercase, which means all letters will be in lowercase.

And this last paragraph has a text-transform property applied with the CAPITALIZE property. The first letters of each word will be capitalized, and only they.

Result

However, not all so simple. There are some nuances. If you pay attention to the second paragraph of the above example, you will notice that the word capitalize , despite the text-transform property applied to the paragraph with the value capitalize , is displayed entirely in uppercase letters, which corresponds to the source text. This is explained by the fact that with the specified value of capitalize, only the first letters of words are checked, and the rest remain unchanged, regardless of their initial state.
Despite its apparent simplicity, the text-transform property can be very useful. For example, in order to make the text of all H1 headings of your site capitalized, you just need to add one property to the style sheet

H1 (text-transform: uppercase;)

and the problem will be solved. And you do not need to manually change all the headers, which can be very, very many.

Good day, site building geeks. Today's post will cover the topic of design. text content. That is why you will learn how css capital letters are set - by means, get acquainted with several options for creating a capital letter and, of course, you can try everything out in practice. Well, now let's move on to the most interesting!

Let's Transform Text

Thanks to cascading style sheets, you can change both the first character of a block and the entire text. I will tell you how you can do both options. Moreover, all the tools mentioned in this article are supported in three language levels: css1, css2, css2.1 and css3.

I'll start with an interesting property that modifies all text content in the selected . it text-transform.

The named element can convert characters to uppercase, lowercase, and also set every first character of a word as a capital letter. I wrote more about the values ​​​​in the table.

Now, to consolidate the theoretical material, consider an example.

Text transformation

Attention!

!Tomorrow all beauty products are discounted!

The promotion is valid in all branches located in your city.

Creating a drop cap

If you don’t know what the term “letter letter” means, then it’s time to find out, as this is directly related to the current topic.

The initial letter (or sometimes they say the initial) is the first letter of the chapter, which differs from the rest in its large size, color, and in some cases even font design. In life, an example of such a letter can be found in old manuscripts and books.

There are several ways to create an initial. Often a character is highlighted with a markup language tag and after in styles prescribe certain properties that modify it. This is a good way, but this publication talks about css mechanisms (which, in my opinion, are much more logical and convenient to use in this case).

To solve this problem, you can use a tool such as.

So, in this case: first-letter is used. Like all pseudo-elements, it is appended to the selector with a colon. After all the rules of style sheets, properties are specified. However, you can apply only those properties that are related to editing fonts, indents, colors, background, margins and borders.

I propose to consider specific example. Implementing the presented small program, I decided to make not just a colored drop cap, but fill it with flowers. To do this, you need to use a few tricky tricks with setting the font color to transparent and filling the letter with the selected image.

Protruding initial

This paragraph contains a very interesting sentence.

Let's continue the interesting story in the next paragraph.

The result obtained looks very attractive and unusual, which is ideal solution for .

As you can see, this topic is very simple. brought by me programming code you can easily use for your web resources, modifying and adjusting to your style.

If the material presented was useful to you, then subscribe to my blog updates and do not forget to share your knowledge (and, of course, a link to my blog) with your friends. Good luck!

Bye Bye!

Sincerely, Roman Chueshov

CSS capital letters help to break the monotony of the same type of design, the texts of which look the same from beginning to end.

Letters then and now

The chroniclers used capital letters in handwritten manuscripts, some of which date back to the 5th century. Capital letters continued to be used from the 8th to the 15th century, when printing presses made it possible to bring printing to an industrial level. Both handwritten and printed capital letters were placed at the beginning of the text. Often they were decorated with a decorative pattern that was located around the letter.

The raised and lowered letters are still in use today. They can be found in newspapers, magazines and books, as well as in digital printing. Raised letters are sometimes called elongated. They are located on the same level as bottom the text that follows them. Dropped letters are placed flush with the top of the text, sometimes in a layer behind the main body of text content, or the rest of the text wraps around them.

Raised letters are much easier to define as they sit flush with the rest of the text and usually don't need to change the wrapping of the outer margins. Omitted letters require more fine tuning. It will be easier for you to deal with this if you first understand how lifted characters are handled.

Using classes

Designers who already have an understanding of CSS know to create a separate CSS class for the first capital letter.

The CSS code for the paragraph element and the class that creates the letter would look like this:

p ( font-size:20px; font-family: Georgia, "Times New Roman", Times, serif;) .myinitialcaps (font-size:48px; font-family: Didot;)

And the HTML code will look like this:

What gives us:

Seems too easy? In fact, you will have to make adjustments depending on the specific raised letters, since each capital letter requires special kerning. After choosing a font for the raised letters and for the body text, you need to create separate classes for each raised letter. In the below CSS class.myinitialcapsi the margin on the right is negative to reduce the distance between I and n .

Myinitialcapsi(font-size:48px; font-family: Didot; margin-right:-1px;)

I n this case, there's some extra space between the “I” and “n.”

I ncluding a new class with a negative margin pulls it closer.

Depending on the screen resolution in the example above, I and n might look like they've merged together. This is due to the serifs at the ends of the letters. Therefore, before choosing the final CSS styles, test the site on various devices to see how CSS text looks on them.

Quotes and other special cases

You can increase not only the letters at the beginning of the text. You can implement another class to create a larger version of the quotation marks that will appear next to the letter. In our case, neither the letter class with a size of 48 nor the text class of 20 pixels is suitable for quotes. Rather, it will be something in between - 30 pixels. We move the quotation marks down by 4 pixels to optically align them with I :

Myinitialcapsq (font-size:30px; font-family: Didot; float:left; margin-top:4px;)

I ncluding” a new class with a negative margin pulls it closer.

You need to be very careful when specifying each of the CSS capital letters along with the quotation marks so that their kerning and alignment matches the surrounding markup. For example, the letter T will need to be moved to the left, slightly beyond the edge of the paragraph, so that its transverse line visually fits into the layout. You will need to do the same with round letters such as C , G , O and Q . This example uses font sizes 20, 30 and 48. But you will need to adjust the sizes based on the specific fonts you have chosen. As well as the sizes and resolutions of the screens on which the site will be viewed.

Pseudo-elements and pseudo-classes

Using the CSS pseudo-element, you can easily create a raised letter by adding ::first-letter to the paragraph element. Use :first-letter ( with one colon) for legacy browsers:

p ( font-size: 1.2em; font-family: Georgia, "Times New Roman", Times, serif; line-height:2em; padding-bottom:1.2em;) p::first-letter ( font-size: 3.6em; text-transform: uppercase; font-family: "Monotype Bernard Condensed", serif; margin-right:0.03em;) .initialb (margin-right:-0.1em;) .initialn (margin-right:-0.15 em ;)

An HTML code that contains CSS classes that take into account the kerning of the letters N and B will look like this…

An inital letter, with the first letter being a capital letter.
With a line break, the next line has no initial cap.

n otice in the HTML source how the first letter, not a capital letter in the HTML, gets sized to the initial cap size of 3.6em. Neat, huh?

B ut with a hard return, and a new paragraph started, another initial cap always gets created. You might be asking yourself How am I going to account for this? Am I supposed to have an initial cap at the beginning of very new paragraph? Well, you could. But, do you want it to look that way, and does it absolutely have to look that way?

The first capital letter of a paragraph is converted to a letter.
The first letter after a line break will not be capitalized.

about Please note that in source code In HTML, the first letter is not capitalized, but it is converted to a 3.6em character.

O However, even after a forced line break, a letter is always created at the beginning of each new paragraph. You may ask yourself: How can I take this into account? Do I need to add letters for all these cases? Well, you can. But is it necessary?

Even with the benefits that pseudo-elements provide, we had to add a lot of code to define separate classes to handle kerning and padding issues. But this method will convert the first letter of each new paragraph to CSS capitalization. For some, it may not be suitable, because you do not need to convert the first letter of each paragraph.

Combining Pseudo-Classes and Pseudo-Elements to Create a Smart Layout

Adding the :first-child pseudo-class helps to solve the problem of unnecessary conversion of the first letters:

p ( font-size: 1.2em; font-family: Georgia, "Times New Roman", Times, serif; line-height:2em; padding-bottom:0.5em;) p:first-child::first-letter ( font-size: 3.6em; text-transform: uppercase; font-family: "Monotype Bernard Condensed", serif; margin-right:0.03em;)

Combining this code with HTML :

The first letter that is defined as first-child is the only letter that converts to a raised drop cap in this method.

Since only the letter defined as first-child is converted, note that this example differs from the previous one without first-child. In addition, we do not convert the first letters after the beginning of a paragraph and after a forced line break. This looks more elegant than how the layout looked when we converted all the first letters of the paragraphs.

The advantage of using pseudo-classes is the ability to handle various special cases. What about disadvantages? There are many different pseudo-classes, and they can be combined in so many ways that it can make your head spin. For example, the pseudo-classes :first-child and :first-of-type can produce the same results. You can also apply a pseudo-class not only to a paragraph, but also to elements

or
. For example, as shown in the example below with raised letters in the Didot font. Notice how the margin attribute has been added to the right of the A . Otherwise, it would “stick together” with the letter s at the beginning of the section:

section ( font-size: 1.2em; font-family: Georgia, "Times New Roman", Times, serif; line-height:3em;) section>p:first-child:first-letter ( font-size: 4em; text-transform: uppercase; font-family:Didot, serif; margin-right:5px;)

And along with HTML :

At the beginning of the section, the first letter is set to a raised capital letter.

And a new paragraph...

If you feel like experimenting, you can explore various methods in addition to :first-child and :first-of-type . For example, such as :nth-of-type or :nth-of-child , to see how certain pseudo-class types can be used for CSS capitalization text. Whether you follow the principles outlined in this article or start digging deeper, once you learn how to work with the first-child , :first-of-type , and :first-letter CSS pseudo-classes, you will be able to properly apply them to HTML elements.

In html, font size plays an important role. It draws 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 working with html fonts

The hypertext language has big set font tools. After all, text formatting is the main task of html .

Cause of creation HTML language there was a problem of displaying text formatting rules by 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 ​​of its attributes, you can set several font characteristics:

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

A positive attribute value from 1 to 7 is supported.

  • face - used to set the font family of the text to be used inside the tag . Multiple values ​​are supported, separated by commas.

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

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

  • - sets the bold font in html. Tag similar in action to the previous one;
  • - the size is larger than the default;
  • smaller size font;
  • - italic text (italic). Similar tag ;
  • — text with underlining;
  • - crossed out;
  • — displaying text only in lower case;
  • - in upper case.

plain text

Thumbnail

Thumbnail

More than usual

Less than usual

Italics

Italics

With underline

Strikethrough

Style Attribute Capabilities

In addition to the tags described, 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 font display style:

1) font-family - property sets the font family. It is possible to enumerate 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 in which 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 terms ( 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 font style. Syntax:

font-style: normal | italic | oblique | inherit

Values:

  • normal - normal spelling;
  • italic - italic
  • oblique - font with an inclination 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 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 text writing (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 terms.

font-weight:bold

font-weight:bolder

font-weight:lighter

font-weight:normal

font-weight:900

font-weight:100

font property and html font color

Font is another container property. Internally, it combined the values ​​of several properties designed to change fonts. Font syntax:

font: font-size font-family | inherit

Also, the value can be set to the fonts used by the system in the inscriptions on various elements 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

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

or more about letters and HTML CSS formatting

Chapter contains examples letter formatting from the Hypertext Markup area.

In the menu on the left you will find modern and very detailed HTML tutorials.

They will allow you to create your website with clean slate while looking a little lower.

It might be interesting.

Epoch information society

Humanity has entered a new period of its development, in which information and network technologies play an extremely important role. We live in the era of the information society, which is characterized by the rapid development of information and telecommunication technologies. With the advent of the computer and the Internet, tremendous changes began. The computer and the Internet are pushing society to formulate new norms of behavior, rules and ideals. The Internet is to the new generation what television was to the previous generation. But the Global Network is much more functional than television, because it provides an opportunity to make purchases, sales, offers communication and various ways self-expression, such as creating personal web pages and sites.

HTML letters: upper and lower case

Letter formatting example:

Format result:

An example of free text written in capital letters

An example of free text written in capital letters

tags - determine capital letters(These tags are not supported in HTML 5).

css code style="text-transform:uppercase" - defines capital letters.

In other words, capital letters are defined with using CSS attributes.

HTML letters and CSS spacing between them

Letter formatting example:

Format result:

Arbitrary HTML text and CSS spacing between letters in 2 pixels

Description of attributes and values:

css code style="letter-spacing:2px" - defines CSS letter spacing.

Look for similar formatting examples in the menu on the left. Thank you for your attention.