Difference between Internal,  External and Inline CSS with their priority






Type Priority
Inline CSS Highest priority
Internal CSS Medium priority
Lowest CSS Highest priority





Inline CSS:


An inline css may be used to apply a unique style for a single element. The inline styles loses many of the advantages of style sheets by mixing content with presentation. Use this maethod sparingly.

To use inline styles, you use the style attribute in a relevent tag. The style attribute can contain any CSS property. The syntax for inline style sheet is given below.

<tag style="property:value;">

Eg: <p style="color:red;">


Internal CSS:


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, like this:



<head>
<style type="text/css">
hr 
{
color:sienna;
}
{
margin:20px;
}
body 
{
background-url:("images/back 40.gif");
}
</style>
</head>


External CSS


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

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



An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet
should be saved with a .css extension. An example of a style sheet file is shown below:

hr 
{
color:sienna;
}
{
margin:20px;
}
body 
{
background-url:("images/back 40.gif");
}

Do not add a space between the property value and the unit (such as margin-left:20 px). The correct way is:
margin-left:20px;


Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Enhancing Supply Chain Security and Cloud-Native Development with Chainguard