back

</>CodeWithRahul

More
  • Home
  • Cources
  • Tutorials
  • Tutorials
  • Projects
  • Notes
  • Contact
  • Work With Us
  • HTML
  • CSS
  • JAVASCRIPT
  • CC++
  • PHP
  • PYTHON
  • REACT JS
  • DSA

</>Code With Rahul

Create an account
  • INTRODUCTION
    • Information & History
    • Your first CSS Website
    • How CSS Works?
    • Ways to add CSS
    • CSS Selectors
    • CSS Comments
  • CSS Properties
    • CSS colors
    • CSS backgrounds
    • CSS Borders
    • CSS Image
    • CSS Videos Embedding
    • CSS Fonts
    • CSS Text Styling
    • CSS Padding
    • CSS Margin
    • CSS Hover
    • CSS Links
    • CSS Combinators
    • CSS Pseudo Classes
    • CSS Buttons
    • CSS Overflow
    • CSS Float
    • CSS !Important
    • CSS Maths Function
    • CSS Size
    • CSS Positioning
    • CSS Z-index
    • CSS Forms
    • CSS Navigation
  • CSS Designing
    • CSS Display
    • CSS FlexBox
    • CSS Grid
    • CSS Meida Queries
  • CSS Advance Topics
    • CSS CSS 2D
    • CSS Transform
    • CSS Transition
    • CSS Border Image
    • CSS Gradients
    • CSS Inherit
    • CSS Shadows
    • CSS ToolTip Text
    • CSS Border Image
    • CSS Masking
    • CSS Pagination
    • CSS Meida Queries Advance
    • CSS Animation
  • CSS FAGS
    • CSS Questions

    CSS Text Styling

    In this tutorial, we will cover some of the important text styling properties:

    Font Color

    The text-decoration property adds various types of text decorations.

    Syntex

    <style>
        selector {
            text-decoration: value;
        }
    </style>

    There are four values for text-decoration:

    Font Size

    overline: adds a line above the text
    underline: adds a line below the text
    line-through: Adds a line to the text.
    none: To remove decoration.

    Example:

    <html lang="en">
    <head>
            <style>
                #p1 {text-decoration: overline}
                #p2 {text-decoration: underline}
                #p3 {text-decoration: line-through}
                #p4 {text-decoration: none}
            </style>
    </head>
        <body>
        <p id="p1">Text-decoration: overline </p>
        <p id="p2">Text-decoration: underline</p>
        <p id="p3">Text-decoration: line-through</p>
        <p id="p4">Text-decoration: none</p>
    </body>
    </html>

    Output

    font excation

    Text Alignment

    The text alignment property is used to align the text within the container. Container can be a div, section, etc.

    syntex

    <style>
        selector{
            text-align: value;
        }
    </style>

    Font Size

    left: align the text to the left.
    right: align the text to the centre.
    center: align the text to the right.
    justify spread the text evenly between the left and right margins.

    Example:

    <html lang="en">
    <head>
            <style>
                #p1 {text-align: left}
                #p2 {text-align: right}
                #p3 {text-align: end}
                #p4 {text-align: justify}
            </style>
    </head>
        <body>
        <p id="p1">Text-align: left</p>
        <p id="p2">Text-align: right</p>
        <p id="p3">Text-align: end</p>
        <p id="p4">Text-align: justify</p>
    </body>
    </html>

    Output

    font style

    Text Transformation

    It transforms the text case.

    syntex

    <style>
        selector{
            text-transform: value;
        }
    </style>

    There are four values for text-transform:

    uppercase: Transform text to uppercase (all capital letters).
    lowercase: Transform text to lowercase (all small letters).
    capitalise: capitalise the first character from each word.
    none: To remove text transformation.

    Example:

    <html lang="en">
    <head>
            <style>
                #p1 {text-transform: uppercase}
                #p2 {text-transform: lowercase}
                #p3 {text-transform: capitalise}
                #p4 {text-transform: none}
            </style>
    </head>
        <body>
        <p id="p1">Text-transform: uppercase</p>
        <p id="p2">Text-transform: lowercase</p>
        <p id="p3">Text-transform: capitalise</p>
        <p id="p4">Text-transform: none</p>
    </body>
    </html>

    Output

    text transform

    Letter Spacing

    The letter-spacing property allows to specify the spacing between each character in the text. The property values can be in pixels (px), em, rem, percentage (%), etc.

    Example:

    <html lang="en">
    <head>
            <style>
                    h1{
                        letter-spacing:8px;
                    }
            </style>
    </head>
        <body>
            <h1>CodeWithRahulGoswmai</h1>
        </body>
    </html>

    The value of 3.5 means that the space between lines will be 3.5 times the height of the font size.

    Output

    letter spacing property

    Line Height

    The line-height property controls the spacing between the two lines of text.

    Example:

    <html lang="en">
        <head>
            <style>
                    h1{
                        letter-height:5px;
                    }
            </style>
        </head>
        <body>
            <h1>CodeWithRahulGoswmai</h1>
            <h1>Learn Programming Online</h1>
        </body>
    </html>

    Output

    Line Height property

    Text Shadow

    The text-shadow property adds a shadow to the text.

    Syntex:

    <style>
        selector{
            text-shadow: Horizontal offset, vertical offset, blur radius, color;
        }
    </style>

    Example:

    <html lang="en">
        <head>
            <style>
                    h1{
                        text-shadow: 2px 3px 4px red;
                    }
            </style>
        </head>
        <body>
            <h1>CodeWithRahul</h1>
        </body>
    </html>

    Output

    text-Shadow

    Text Overflow

    The text-overflow property handles text that overflows its container.
    There are two values we can use with text-overflow:
    ellipsis: Truncates overflowing text with an ellipsis.
    clip: clips the text without any visual indication.
    Owner of this WebPage Image

    CodeWithRahul

    Copyright © 2023 CodeWithRahul.com