This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Monday 22 April 2013

CSS ID & Class


CSS ID & Class:


  CSS ID

  • The ID attribute of a document language allows authors to assign an identifier to one element instance in the document tree.
  • CSS ID selectors match an element instance based on its            identifier.
  •  A CSS ID selector contains a "#" immediately followed by the ID value, which must be an identifier. 



How to use

        <p id="bordered">

                 Then,

         #bordered 
         {
                 border : 1px solid black ;
         }



   Example
  
      #top 
         {
         background-color: #ccc;
         padding: 1em
         }

  <p id="top">This is my recipe for making curry purely with chocolate</p>


 CSS Class

  • A CSS class selector applies to many elements at once, or a sub-set of specific HTML elements. 
  • To use them, you need to edit your HTML to define the classes on the HTML elements you want styled.
  • Then you define the style in your style sheet. 


How to use

.className 
{
declaration block
  }

Example

<style>
.center
{
text-align:center;
}
</style>

<p class="center">Center-aligned paragraph.</p>


Output

Center-aligned paragraph.


CSS Syntax


CSS Syntax:

Syntax

selector { property: value }

Description

  1. The selector is normally the HTML element you want to style.
  2. Each declaration consists of a property and a value.
  3. The property is the style attribute you want to change. Each property has a value.


Example

h1, h2, h3, h4, h5, h6 {
  color: #009900;
  font-family: Georgia, sans-serif;
}

HOW To Insert CSS



HOW To Insert CSS

There Are Three ways to insert Stylesheet
1)External Stylesheet
2)Internal Stylesheet
3)Inline Stylesheet

1)External Stylesheet

  • External stylesheet are the best way to put CSS styles on your web pages.
  • Once you've gone beyond the basics of creating CSS styles, you'll want to be able to use the same styles across multiple pages on your site.
  •  External style sheets make this easy to do.
  • Authors may separate style sheets from HTML documents. This offers several benefits:

  • Authors and Web site managers may share style sheets across a number of documents (and sites).
  • Authors may change the style sheet without requiring modifications to the document.
  • User agents may load style sheets selectively (based on media descriptions).

How to Use

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

An external style sheet is ideal when the style is applied to many pages. 
With an external style sheet, you can change the look of an entire Web site by changing one file.
Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section.

Example
<html>

<head>
<title></title>

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

</head>

<body>
...web page content...
</body>

</html>

2)Internal Stylesheet

An internal style sheet should be used when a single document has a unique style. 
You define internal styles in the head section of an HTML page, by using the <style> tag.
When using internal CSS, you must add a new tag, <style>, inside the <head> tag.
Unlike inline styles, internal style sheets can still take advantage of classes, IDs, siblings, and other element relationships.

How to Use

<style type="text/css" media="all">
 <!--
 p { font: 1em Times serif; color: #c00; }
 h1 { font: 2em Times serif; color: #f00; }
 -->
 </style>

Example

<html>
<head>
<style type="text/css">
 
p {color: red; }
</style>
</head>
<body>
<p>Hi this is internal css!</p>
</body>
</html>

Output

Hi this is internal css!

3)Inline Stylesheet

To use inline styles you use the style attribute in the relevant tag.
The style attribute can contain any CSS property
CSS Styles with the Style Attribute and No Style Sheet.
Because of the cascade, inline styles have the highest precedence.

How to Use

<H1 STYLE = "Color: Red">My Heading </H1>
  • To place a style in a HTML tag:
  • Type the Tag you want to chang
  • Next, type a space and then the word STYLE
  • Type an equals sign ( = ) after the word STYLE
  • Type the Property followed by a colon
  • Type the Value
  • Type the right angle bracket ( > ) of the HTML tag
Example

<H1 STYLE = "Color: Red">My Heading </H1>

Output

My Heading

CSS Introduction


CSS Introduction

What is CSS?

  • CSS stands for Cascading Style Sheets.
  • CSS is an extension to basic HTML that allows you to style your web pages.
  • External Style Sheets can save a lot of work.
  • External Style Sheets are stored in CSS files.

Use Of CSS
  • Use of CSS is the recommended way of defining how HTML pages are displayed. 
  • You should use HTML to define the basic structure (using elements such as <h1>, <p>, <li>, etc.) and CSS to define how these elements should appear (e.g. heading should be in bold Arial font, paragraphs should be indented, etc.).


Applied the style

      <style type="text/css">
      .myNewStyle 
      {
   font-family: Verdana, Arial, Helvetica, sans-serif;
           font-weight: bold;
           color: #FF0000;
      }
      </style>
 
        In the above example we embed the css code directly into the page itself.


Example

<div style="width:150px; height:150px; 
margin:0 auto; border:1px black solid; background:#ddd;text-align:center;">This is my box</div>

Output

In middle of  div the text “This is my box”  display.

Twitter Delicious Facebook Digg Stumbleupon Favorites More