External Style Sheet

Creating and Using External Css File

If we are going to use the styles we will create on all pages on our site, add these style templates to the extension. We can write it in a file with css.

By linking this style file to the web pages we want, we can make it valid for those pages.

In this way, when we want to make a changes in the design of the site, we can change all the pages by simply editing this file.

To apply a style file to a web page, we must add the following code to the head of that web page:

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

Inside the external style file, our styles can be written as follows:

body {
font-family: Verdana, Geneva, sans-serif;
font-size: 10pt;
color: #000;
}
 
.important{
font-weight: bold;
color: #F00;
text-decoration: underline;
}
 
#header {
font-size: 48pt;
font-weight: bold;
background-color: #CFF;
}
...
...

Using Multiple Style Files

Multiple style files can also be linked to a web page. If the same tags or selectors are defined in different style files and the same properties are formatted differently, the properties in the last read style sheet will be valid.

This also applies if the property is formatted both in the external style file and in the head .

Let's explain this with an example.

In the style1.css file for the h1 tag;

h1 { color: blue; }

In the style2.css file;

h1 { color: red; }

get it written. Let the head of the document look like this:

<style type="text/css">
 
h1 { color: green; }
 
</style>
 
<link href="style2.css" rel="stylesheet" type="text/css" />

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

In this case, the h1 tag will be blue. Because the last style file read is stil1.css and h1 is made blue in that file.

Not to mention: Native style templates have the highest priority. A style specified in the tag will override any rules in the head or external style file.

advantages of using external style sheet, external css file, how to use external css sheet

EXERCISES

Web sitelerinin CSS kodlarını görme

Ziyaret ettiğimiz bir sitenin CSS kodlarını görmek için;

Sağ tıklayarak "Kaynağı Görüntüle" komutu verin.

Gelen Html kodları arasında Head kısmında harici dosyanın belirtildiği yeri bularak, dosya ismine tıklayın. 

Harici Css dosyası görüntülenecektir.



COMMENTS




Read 617 times.

Online Users: 38



using-css-external-sheet