Saturday, April 14, 2012

How to define a CSS in Blogger Blog?

We saw How to define a CSS in general HTML?.In blogger,
Places where CSS and HTML used together?
  • In posts.
  • In HTML/Java Script Gadgets.
  • In Overall Template.
In Posts :-
  1. The CSS is defined in the HTML part of the post at the top. For example,
    <style type="text/css">
    .textborder{border:0.5px solid black;}
    </style>
  2. The above code should be pasted at the top of the post. Therefore the post will look like,
    <style type="text/css">
    .textborder{border:0.5px solid black;}
    </style>
    <div>
    <div class="textborder">body of the post</div>
    </div>
  3. The life span of the style is the life span of the post.
In HTML/ Java Script Gadgets:-
  1. Same way as first step, but the you needa place the style in a HTML gadget.
  2. HTML/Java Script Gadget? :-
    • Dashboard => Design => Page Elements(if necessary) => Add a gadget => HTML/Java Script [Old UI]
    • Dashboard => Layouts => Add a gadget => HTML/Java Script [New UI
  3. Place the code as below in the gadget.
    <style type="text/css">
    .textborder{border:0.5px solid black;}
    </style>
    <div>
    <div class="textborder">body of the HTML Gadget</div>
    </div>
  4. The Life span of the style is the life span of the HTML/Java Script Gadget.
In Overall Template:-
   Two ways again :-
  1. Go to Add CSS option:-
    • Dashboard => Design => Template Designer => Advanced => Add CSS [Old UI]
    • Dashboard => Template => Customize => Advanced => Add CSS[New UI]
    Just Paste the code without <style/> tag. Like below
    .textborder{border:0.5px solid black;}
    Click Apply to Blog. 
  2. Go to HTML Template Editor. Press Ctrl + F. Find the following code.
    ]]></b:skin>
    Paste the CSS that you pasted in previous step just above the found code. Save Template.
How to use the css?
  • When you place the CSS in a template, you can use it anywhere inside the Blog. You should just enclose with <div/> tag.
  • Like this:-
    <div class="textborder">Body of the HTML gadget/Post/Template</div>
  • The life span of the style is the life span of the blog.

    No comments :

    Post a Comment