Text - Text in CSS
Text colors
Color properties are used to change colors for text, which can be determined by:
- color name - like: 'red'
- HEX value - like '# ff0000'
- RGB value - like 'rgb (255, 0, 0)'
The default color for the page will be defined in the body section.
body {
color: blue;
}
h1 {
color: green;
}
Note: For CSS to comply with W3C, when defining color, you must define both background-color.
Align text
The text-align
is used to align text horizontally: left, right, center, or marginal alignments on both sides. These are text examples that align with the center, left and right. The text direction from left to right default to left, right-to-left right-aligned text aligns right.
h1 {
text-align: center;
}
h2 {
text-align: left;
}
h3 {
text-align: right;
}
Example of text alignment
When the text-align
is selected as justify
, each line will have equal width, the text is aligned in both left and right margins.
A piece of text is aligned on both sides
Other format for text
The text-decoration
is used to add or remove some other text formats. text-decoration: none
value text-decoration: none
normally used to remove the underlined paragraph in the path.
a {
text-decoration: none;
}
Other text-decoration
values also include underscores, dashes and underscores.
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
Note: Normally, it is not advisable to underline the text not the path because it is easy to confuse the reader.
Text-decoration feature for other special formats
Set lowercase and uppercase letters for text
The text-transformation
is used to identify lowercase and uppercase letters in text. It can turn both text into lowercase, uppercase or just capitalize the first letter of each word.
p.uppercase {
text-transform: uppercase;
}
p.lowercase {
text-transform: lowercase;
}
p.capitalize {
text-transform: capitalize;
}
Head off the text
The text-indent
is used to determine the beginning of the first line of the text.
p {
text-indent: 50px;
}
Distance between letters
The letter-spacing
used to determine the distance between letters. The example below shows how the gap increases / decreases.
Specify the letter-spacing letter spacing
Height of the line
The line-height
defines the height of the line, or the distance between the lines. The default line height on most browsers is usually about 110% to 120%.
p.small {
line-height: 0.8;
}
p.big {
line-height: 1.8;
}
Examples of lines between lines in CSS
Text direction
The feature direction
is used to change the direction of the text in the element. Text can be written from left to right (default) or from right to left 'rtl'.
p {
direction: rtl;
}
Distance between words
The word-spacing
used to determine the distance between words in the text.
h1 {
word-spacing: 10px;
}
h2 {
word-spacing: -5px;
}
Text shading
The text-shadow
helps to add shadows to text. The example below shines 3px horizontally, the shadow is vertical 2px and the color of the shadow is red.
h1 {
text-shadow: 3px 2px red;
}
Last lesson: Outline in CSS
The following article: Font in CSS
You should read it
- Word 2013 Complete Tutorial (Part 9): Use Line and Paragraph Spacing
- Spacing, spacing words in Word
- How to fix the line spacing when aligning in Word
- How to align text in a cell in Excel
- Control formatting when pasting text in Word
- How to rotate text in Word
- Format text in HTML
- MS PowerPoint 2007 - Lesson 5: Format text in PowerPoint
May be interested
- How to use Live Text OCR on iOS 15one of the handy new features coming to ios 15 is the option to quickly recognize text and select, copy, paste, and lookup in both the camera and photos apps.
- How to insert Text Box in Word simply, anyone can do ittext box in word helps you create a prominent text frame, increasing the aesthetics of the text. with just a few simple steps, you can insert and customize the text box as you like. let's find out how to do it right after.
- What is Text Replacement on iPhone? Why is it useful?if you're tired of typing the same text over and over again, the iphone's text replacement feature is the solution. it's simple, powerful, and has quietly changed the way people communicate every day.
- How to export text in images using the OCR Text Detection Toolto export text from an image, the ocr text detection tool application on windows 10 will support a simple operation.
- Instructions for setting up reading text content on a Macwith a mac, users can completely set the text reading mode, all the text content that the user chooses.
- How to transfer text code with Unikeyif you have ever encountered a full-text word file that is .vntime, you would like to copy a piece of this text to another text with a font that is vni-times or unicode font. trouble due to heterogeneity between text codes.
- 6 best Android OCR apps for extracting text from photosdo you want to digitize any printed document to keep a soft copy of it? if so, all you need is an optical character recognition (ocr) tool. there are several online ocr tools, but it is not convenient to digitize documents by phone. here are 6 best ocr apps for android.
- Enable Text-to-Speech feature in iOStext-to-speech (built-in text to speech) is built into the ios operating system. however, for many new iphone or ipad users, this feature is not yet known.
- How to enable or disable text suggestions on Windows 10on windows 10, you can use the text suggestion feature (text suggestion), it will display the text you intend to type next, saving time and typing faster.
- How to quickly create new blank text files on Windows, Mac and Linuxtext file is useful for everything. recording a note, storing information, and journaling are just a few of the many things you can do with text files. today, we will show you how to create new blank text files in windows, mac and linux quickly. in windows, it is easy to locate new text files. but on mac and linux, this job requires some initial setup, then creating a new text file is also quick and easy.