Skip to main content

Command Palette

Search for a command to run...

Text in CSS:

Updated
•2 min read•View as Markdown

Text in CSS: In CSS(Cascading Style Sheets), text can be styled using various properties. Some examples have been given below:

  1. Text color: This property is used to set the color of the text. It can be set in various ways such as by using a color name, RGB values, or hexadecimal values. Example: color: red;

  2. Text alignment: This property is used to set the horizontal alignment of the text within its container. It can be set to left, right, centre or justify. Example: text-align: centre;

  3. Text decoration: This property is used to add decoration to the text such as underlining, overline, or line-through. For example: text-decoration: underline;

  4. Text transformation: CSS provides the text-transform property, which can be used to transform the case of the text. The text-transform property accepts four possible values: uppercase, lowercase, capitalize, and none. For example, to transform all text to uppercase, we can use: text-transform: uppercase;

  5. Text shadow: CSS provides the text-shadow property, which can be used to add a shadow effect to the text. The text-shadow property accepts three values: the x-offset, the y-offset, and the blur radius of the shadow. For example, to add a black shadow to text with a horizontal offset of 2px, a vertical offset of 2px, and a blur radius of 1px, we can use: text-shadow: 2px 2px 1px black;

  6. Text indentation: The 'text-indent' property sets the amount of space that should be used for the first line of text in a block. For example, to indent the first line of a paragraph by 20 pixels, we can use:

    p {

    text-indent: 20px;

    }

Note: These are just a few examples of the text-related properties. There are many more properties available in css except them. By using these we can customize the appearance of text on our website.

More from this blog

Untitled Publication

21 posts

B.tech (electrical & electronics) graduate but loves to do stuff related computer and always in search of new ideas, fun and knowledge. I hope you enjoy my articles.