Home  >  Article  >  Web Front-end  >  How to set font right alignment in css

How to set font right alignment in css

WBOY
WBOYOriginal
2021-11-09 13:39:2220943browse

In CSS, you can right-align the font through the text-align attribute. This attribute is used to set the horizontal alignment of the text of the specified element. You only need to set the value of this attribute to "right". Syntax "text-align:right;".

How to set font right alignment in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The method for setting the right alignment of fonts in css is as follows:

1. Create a new html file named test.html for explaining css How to set text to right alignment.

How to set font right alignment in css

2. In the test.html file, use the div tag to create a line of text for testing.

How to set font right alignment in css

3. In the test.html file, add a class attribute with the value mykkk to the div tag for setting the style.

How to set font right alignment in css

4. In the css tag, set the style of the div through class, define the width of the div as 400px, the background color as blue, and the text color as white.

How to set font right alignment in css

5. In the css tag, set the text-align attribute to right to right align the text.

How to set font right alignment in css

#6. Open the test.html file in the browser to check the effect.

How to set font right alignment in css

Summary:

1. Use the div tag to create a line of text.

2. In the css tag, define the width of the div, and at the same time, set the text-align attribute to right to achieve right alignment of the text.

Note: The width of the div must be set to achieve the effect.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of How to set font right alignment in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to center text in cssNext article:How to center text in css