BREAKING NEWS

Blogger Security

Css

Javascript

Thursday, May 8, 2014

Css Implementation



There are 4 ways to install the CSS code into the HTML code / web pages, namely :

  1. Inline CSS 
  2. Css embed code or install the part into the <head> 
  3. Embed link to external CSS 
  4. Import CSS file 
Let us discuss one by one ...

Inline CSS

CSS code is written directly into the HTML tags that you want to format. Writing in this way does not require writing a selector in the CSS code.

This method should only be used if you want to format an element only once.

example :
<P style=”color:blue”>
Isi paragraf.
</p>
In the above example, the paragraph element <P> in formats that use blue writing. Another paragraph element, will not use blue, because it applies only to format a paragraph element specified in its CSS code. 

Writing CSS in this way at the start with the word style: then followed with a syntax property: value.

Embedded CSS

You can also paste the CSS code in between the tags <head> and </ head>. Writing CSS in this way begins with <style> tag and ends with the tag </ style>. 

example :
<head>
<style type="text/css" media=screen>
p {color:blue;}
</style>
</head>
In the example above all <P> elements in the web page will be formatted using a blue font.

External CSS

External CSS code written in a separate file that is saved with the suffix. Css. You then need to call the CSS file into all the web pages that you create. This way, you only need to have one set of CSS code that is used for all of your web pages. So there are two steps in the implementation of CSS in this way.

example :


  • You create a file with notepad or another text editor, and named, for example: style.css, and write the css code in the file.

p {font-family: arial; font-size: small;}
h1 {color: red; }

  • The second step is to call the style.css file of all web pages. You do this by entering the code below, in between <head> tag and </ head>

<head>
<link rel=”stylesheet” href=”style.css” type=”text/css”>
</head>
Import CSS

You can also import the CSS in a web page using the import tag.

example :

@import "style.css";
atau
@import url("style.css");
Use of More Than One CSS Code

If there is more than one CSS code for one element, then that will be used is a more specific code.

Suppose in a web page, using external style sheets to format the H1 element as follows :

h1 {
color: red;
text-align: left;
font-size: 8pt
}

While on the same web page, in between there <head> CSS code as follows :

h1 {
text-align: right;
font-size: 20pt
}
Notice how the formatting collide, from external style sheets, text-align = left while internal style sheet, the text-align = right.

In cases like this, then that will be active is more specific code, in this case, the internal style sheet is more specific than the external style sheet.

So, in the example above, the code will be implemented as follows :

color: red;
text-align: right;
font-size: 20pt

Post a Comment

 
Copyright © 2013 Tips & Trik Blog
Powered byBlogger