Friday 14 December 2012

Explain how HTML files access CSS


CSS= Cascading Style Sheets this is used for formatting and coding web sites
HTML is used for page layouts

Inline

The CSS is attached to the HTML element e.g.
<h1 style="color:blue; font-size:12px<h1 style ="color:red;">

One of the advantages of using inline is that it is easier to scroll up in the source, rather than change the whole  source file also website's would load much faster compared to if your using external CSS because it has Lower HTTP requests which mean that Inline loads faster.

0ne of the disadvantages of using inlie is that Inline styles must be applied to every element that you want it to be in also it is the most specific in cascade which means that it can sometimes over ride things which you didnt intend for.
 
Internal
 Internal styles are placed inside the <head> section

<head>
<style>
h1{
color:blue;
}
</style>
</head>
 
This coding only allows for one heading to be edited at the time which means that a new code will be needed for every new heading. Internal styles dont need to be applied to every element like inline styles need to be. Internal also tends to Load slower compared to External and Inline.
 
External
The CSS is used to link a file back to the HTML element  

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

 
External style sheet allows us to reuse styles as many times as we want this is done by linking the external style sheer to other web pages styles only need to be used once because they can then be copied. external style sheets are stored in a different CSS file they can also be written in any text editor. external style sheet are mostly use when there are multiple pages and you need there to be the same style on each web page.

Reference