Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Thursday, August 8, 2019

CSS COLORS

Yash Talaiche
CSS ─ COLORS

       CSS uses color values to specify a color. Typically, these are used to set a color either for the foreground of an element (i.e., its text) or for the background of the element. They can also be used to affect the color of borders and other decorative effects.
         You can specify your color values in various formats.

CSS INCLUSION

Yash Talaiche
CSS -INCLUSION

        



    There are four ways to associate styles with your HTML document. Most commonly used methods are inline CSS and External CSS.

  Embedded CSS - The <style> Element                                        
                     You can put your CSS rules into an HTML document using the <style> element. This tag is placed inside the <head>...</head> tags. Rules defined using this syntax will be applied to all the elements available in the document.

  Here is the generic syntax:
      
             <head>
                      <style>
                           . . . . . . . . .  // Style Rule 
                      </style>
             </head> 


 Example

Following is an example of embed CSS based on the above syntax:

        <head>
              <style type="text/css" media="all">
                   h1{     
                   color: #36C;
                 }
            </style>
     </head>

  Inline CSS - The style Attribute
                                 You can use style attribute of any HTML element to define style rules. These rules will be applied to that element only.

Syntax:
           <element style="...style rules....">


Ex:
      <h1 style ="color:#36C;"> This is inline CSS </h1>

           out put:
                       This is inline CSS

External CSS - The <link> Element
                                               The <link> element can be used to include an external stylesheet file in your HTML document. An external style sheet is a separate text file with .css extension. You define all the Style rules within this text file and then you can include this file in any HTML document using <link> element.

Here is the generic syntax of including external CSS file:

<head>
<link type="text/css" href=" . . . " rel="stylesheet" />

</head>

Ex:
    Consider a simple style sheet file with a name mystyle.css having the following rules:
       
      h1, h2, h3 {
         color: #36C;
         font-weight: normal;
         letter-spacing: .4em;
         margin-bottom: 1em;
         text-transform: lowercase;
     } 

 Now you can include this file mystyle.css in any HTML document as follows:
         <head>
             <link type="text/css" href=" mystyle.css " rel="stylesheet" />

        </head>
        
  CSS Rules :
           
        We have discussed three ways to include style sheet rules in an HTML document. Here is the                 rule to override any Style Sheet Rule.
Any inline style sheet takes the highest priority. So, it will override any rule defined in <style>...             </style> tags or the rules defined in any external style sheet file.
Any rule defined in <style>...</style> tags will override the rules defined in any external style               sheet file.
Any rule defined in the external style sheet file takes the lowest priority, and the rules defined in             this file will be applied only when the above two rules are not applicable.
        
CSS COMMENTS:
         Many times, you may need to put additional comments in your style sheet blocks. So, it is very easy to comment any part in the style sheet. You can simply put your comments inside /*.....this is a comment in style sheet.....*/.
You can use /* ....*/ to comment multi-line blocks in similar way you do in C and C++ programming languages.
  Ex:
         /* This is an external style sheet file */
          h1,  h3 {
          color: #36C;
          font-weight: normal;
          letter-spacing: .4em;
          margin-bottom: 1em;
          text-transform: lowercase;
       }
            /* end of style rules. */
      
    

Tuesday, August 6, 2019

CSS Syntax

Yash Talaiche
Css Syntax

        CSS comprises of style rules that are interpreted by the browser and then applied to the corresponding elements in your document.
 

   A style rule is made of three parts:
            1 >  Selector: A selector is an HTML tag at which a style will be applied. This could be any                            tag like <h1> or <table> etc.

            2 >  Property: A property is a type of attribute of HTML tag. Put simply, all the HTML                                   attributes are converted into CSS properties. They could be color, border, etc.

            3 >  Value: Values are assigned to properties. For example, color property can have the value                       either black or #000000 etc.

 You can put CSS Style Rule Syntax as follows :

               selector { property: value }

     Ex: 
               h1 {
                   color: #778899;                        //light blue color .
            }
Types of Selectors :

         (1) Universal Selectors - The universal selector are the quite simply matches the name of any                    element type, Rather than selecting elements of a specific type 
   Ex: 
       * {
               color: #000000;
               }
   This rule renders the content of every element in our document in black.

     (2)  Class Selectors - You can define style rules based on the class attribute of the elements. All                         the elements having that class will be formatted according to the defined rule.
    Ex:
            .black {
                   color: #000000;
                  }
   This rule renders the content in black for every element with class attribute set to black in our                   document. You can make it a bit more particular.
          
        (3)  ID Selectors - You can define style rules based on the id attribute of the elements. All the elements having that id will be formatted according to the defined rule.
      Ex:
           #black {
                     color: #000000;
                 }
    This rule renders the content in black for every element with id attribute set to black in our                      document. You can make it a bit more particular.
     (4)  Child Selectors - You have seen the descendant selectors. There is one more type of selector, which is very similar to descendants but have different functionality.
     Ex:
         body > p {
                color: #000000;
           }
   This rule will render all the paragraphs in black if they are a direct child of the <body> element.           Other paragraphs put inside other elements like <div> or <td> would not have any effect of this             rule.
        (5) Attribute Selectors - You can also apply styles to HTML elements with particular attributes. The style rule below will match all the input elements having a type attribute with a value of text:
Ex: 
           input[type="text"]{
              color: #000000;

            }
  The advantage to this method is that the <input type="submit" /> element is unaffected, and the            color applied only to the desired text fields.

    Grouping Selectors - You can apply a style to many selectors if you like. Just separate the selectors with a comma, as given in the following example:

             h1, h2, h3 {
                 color: #36C;
                 font-weight: normal;
                 letter-spacing: .4em;
                 margin-bottom: 1em;
                text-transform: lowercase;
            }
      This define style rule will be applicable to h1, h2 and h3 element as well. The order of the list is       irrelevant. All the elements in the selector will have the corresponding declarations applied to them.

About CSS

Yash Talaiche
CSS ( Cascading Style sheets)

                  CSS is used to control the style of a web document in a simple and easy way. CSS stands for Cascading Style Sheets.
                               CSS is easy to learn and understand but it provides a powerful control over the presentation of an HTML document. Most commonly, CSS is combined with the markup languages HTML or XHTML.
      CSS handles the look and feel part of a web page. Using CSS, you can control the color of the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what background images or colors are used,and many more.


                                                  
  

Advantages of CSS 
     1.CSS saves time - You can write CSS once and then reuse the same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many web pages as you want.
     2.Easy maintenance - To make a global change, simply change the style, and all the elements in all the web pages will be updated automatically.
   
     3.>  Pages load faster - If you are using CSS, you do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag. So, less code means faster download times.

    4.Global web standards – Now HTML attributes are being deprecated and it is being recommended to use CSS. So it’s a good idea to start using CSS in all the HTML pages to make them compatible with future browsers.