Page 81 - Trackpad_V1_Book 6_Flipbook
P. 81

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 of style rules that are interpreted by the web
                 browser and then applied to the corresponding elements in the HTML web page.


                 SYNTAX OF CASCADING STYLE SHEET

                 The Cascading Style Sheets 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 for 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;”>


                                                                                            Learn HTML5 and CSS3  79
   76   77   78   79   80   81   82   83   84   85   86