Cascading Style Sheet
Cascading Style Sheet (C.S.S.)
Cascading Style Sheet – the cascading style sheet is a language for a webpage to style the webpage. The World Wide Web Consortium (w3C) created CSS.
CSS describes how Html elements are to be displayed on the screen, on paper, or in other media. CSS saves a lot of work.
It controls the layout of multiple WebPages all at once. CSS solved a big problem Html was never intended to contain tags for formatting a web page Html was created to describe the content of a web page like
<h1> this is a heading</h>
<p>this is a paragraph</p>
When tags like<font> and color attributes were added to the html3.2 specification,
It started a nightmare for web developers. Development of large websites, where fonts and color information were added to every single page, became a long and expensive process to solve this problem,
The World Wide Web Consortium (w3C) created CSS. The CSS removed the style format from the Html page.
There are two types of Cascading Style Sheet
1. External Cascading Style Sheet
2. Internal Cascading Style Sheet
The style definitions are normally saved in external.css
A Cascading Style Sheet file rule consists of a selector and declaration block
Cascading Style Sheet Syntax-
H1 { // here h1 is selector
Color : blue; //color is property and blue is value of property
Font-size: 12 px; // font size is property and 12 px is value of property
}
The selector points to the html element we want to style. The declaration block contains one or more declaration separated by semicolons. Each declaration includes a CSS property name and a value, separated by a colon. Multiple Cascading Style Sheet declarations are separated with semicolons and declaration blocks are surrounded by curly braces
The following image shows how CSS works in this way I created an external CSS file for an Html file or code this name is mystyle.css
Body {
Background color: blue;
}
H1 {
Color: navy;
Margin-left: 20px;
}
Cascading Style Sheet
1
And we create another Html file in which we apply the mystyle.css file externally way. The following image shows an external.html file.
External.html --
<! Doctype html>
<html>
<head>
<link rel =”stylesheet” href=”mystyle.css”>
</head>
<h1>this is a heading</h1>
<p1>this is a paragraph</p1>
</body>
</html>
External Cascading Style Sheet
And the output when we run that external Html file whose content is mystyle.css externally the output shows in the web browser chrome like this image
Internal Cascading Style Sheet
Internal CSS-- an
internal cascading style sheet may be used if one single html page has a unique
style the internal style is defined with in the <style> element, inside
the head section.
Example-- internal Cascading style sheet are defined within the <style> element, inside the <head> section of an html page.
Internal.html
<!doctype.html>
<html>
<head>
<style>
<body {
Background-color: green;
}
h1{
color:
blue;
margin-left:40px;
}
<\style>
<\head>
<\body>
<\html>
The output shows in the following image
Internal CSS
Comments
Post a Comment