CSS - Styles for Text


  • Font color
    This property specify the color of the texts.
    Eg:
    body{
       color : red;
    }

  • Font Family
    font-family property specifies the font face of the texts. Most of them uses arial, Verdana, Times New Roman. You can specify morethan one font seperated by commas. Purpose is that if there is not available the font you specified as first then browser will go to the next font. Font name is not a one word then specify it within the quoted marks.
    Ex:
    p
    {
       font-family: Times, "Times New Roman", serif;
    }

  • Font Size
    font-size property specifies the Size of the Text. It is important to manage font size in the web page. Don't use font sizes for the paragraph looks like a heading or make headings as a paragraph. Use proper HTML tags for the formattings. Value of the Font can be either relative or absolute.
    • Absolute Size
      Set the text to specified size which is useful for the known out put text sizes
    • Relative Size
      Set the size relative to the elements and allows users to change the text sizes in the browser. 
    Ex:
    p
    {
       font-size : 12px;
    }

    body
    {
       font-size : 100%;
    }

    p
    {
       font-size : 0.875em; /* 1em = 16px (default font size)*/
    }


  • font-weight
    font-weight define whether the text is bold or not. Default font weight is normal.
    Ex:
    p
    {
       font-weight : bold;
    }
    a
    {
       font-weight : normal;
    }

  • font-style
    font-style states whether the text is italic or not. Default style is Normal. There is a style called "oblique", simillar to italic but less supported.
    Ex:
    p
    {
       font-style : italic;
    }

  • text-decoration
    text-
    decoration states whether the text is underlined or not. Default value is none. 
    • text-decoration : none;
    • text-decoration : overline;
    • text-decoration : line-through;
    • text-decoration : underline;

  • text-transform
    text-transform property uses to change the case of the text.
    • text-transform : capitalize;
    • text-transform : uppercase;
    • text-transform : lowercase;
    • text-transform : none;

  • Text Spacing
    • letter-spacing - Specify the space between letters
    • word-spacing - Specify the space between words
    • line-height - Define the height of the line
    • text-align - specify the alignment of the text
    • text-indent - indent the first line of the paragraph

No comments:

Post a Comment