Page 86 - ConceptGP_C6_Fb
P. 86

STYLING HTML5 DOCUMENTS WITH CASCADING STYLE SHEETS

                  Cascading Style Sheets or (CSS) are used to define styles for webpages. The latest version of CSS
                  is CSS 3. Earlier, CSS 2 was used. CSS comprises style rules that are interpreted by the web browser
                  and then applied to the corresponding elements in the HTML web page. CSS is the language that
                  describes the look and formatting of a document written in HTML.


                  SYNTAX OF CASCADING STYLE SHEET
                  The Cascading Style Sheet has two parts: selector and declaration.
                                         Selector             Declaration

                                            HI      { Color : Blue; Font-Size : 12 px; }


                                                      Property  Value   Property     Value
                  The selector specifies the element to which we want to apply the formatting and the declaration
                  specifies the formatting to the selector.
                     The property of CSS is used to create a style.
                     Value is the valid value for the property.
                      A semicolon should be used at the end of the property value if more than one property is used.

                  Some of the properties and their values used with the style attribute are given below:



                        Property                             Value                             Description




                    Background-Color      Name of the colour                          Specifies background colour.


                                                                                      Specifies the text colour used
                    Color                 Name of the colour
                                                                                      in the webpage.
                                                                                      Specifies the alignment of the
                    Text-Align            Left, Right, Center, Justified
                                                                                      text.

                                                                                      Specifies the font of the text
                    Font-Family           Name of the font
                                                                                      used in the webpage.
                                          Value is given in Pixels                    Specifies the font size used in
                    Font-Size
                                          The default font size for the text is 16px.  the webpage.

                  The three ways to use CSS in HTML documents are described below:


                  INLINE CSS
                  An inline style is used to apply a unique style to a single element. Inline styles are added directly to
                  an HTML tag by using the STYLE attribute with the tag. Syntax to use the style attribute with a tag:

                                              <TAGNAME STYLE = “PROPERTY:VALUE;”>



                   84   Premium Edition-VI
   81   82   83   84   85   86   87   88   89   90   91