Css

CSS

CSS (Cascading Style Sheets) is a style sheet language that is used to describe the look and formatting of a document written in a markup language. It helps to style and give uniformity to the website.

The advantages of CSS are:
• Device Compatibility
• Faster website speed
• Ability to re-position

The disadvantages of CSS are:
• Cross-browser related issues
• Vulnerable • Lack of security
• Fragmentation

The syntax of CSS is:

Selector {property: value).  
Body {color: yellow; font-size: 13px;}  
Example:  
div {  
width: 320px;  
padding: 10px;  
border: 5px solid gray;  
margin: 0;  
}  

The different types of CSS are:
External CSS:
External CSS is used to make changes on multiple pages. Here CSS is applied on multiple pages. The document doesn’t contain any Html tag and is saved with the .css extension not with .HTML extension.

body {  
background-color: white;  
}  
h1 {  
color: blue;  
margin-left: 10px;  
} 

Internal CSS:
Internal CSS is used to add a unique style for single document.Here CSS is applied on a single document of page. It can affect all the elements of the page. It is written within the head section of html.

<!DOCTYPE html>  
<html>  
<head>  
<style>  
body  
{  
background-color: white;  
}  
h1  
{  
color: blue;  
margin-left: 20px;  
}  
</style>  
</head>  
<body>  
<h1>This is a heading </h1>  
<p> This is a paragraph.</p>  
</body>  
</html>  

Inline CSS:
Inline CSS is used to insert stylesheet in html document.

<!DOCTYPE html>  
<html>  
<body>  
<h1 style="color:blue;text-align:center;">This is a heading</h1>  
<p style="color:red;" >This is a paragraph.</p>  
</body>  
</html>  

The different properties of CSS are:
• Color
• Font-size
• Background-color
• Font- family, etc.

Selector
CSS selector is the HTML element where the CSS is applied.CSS selectors select HTML elements according to their id, class, type, attribute, etc
The attributes and values used with the border property of CSS are:
Attributes values
Border-style [dotted, dashed,solid,double,none,hidden,etc.]
Border-width [in, cm, px, pt etc]
Border-color [name of color]
Border-side [top, left, bottom, right]