CSS PROGRAMS
Inline CSS: Inline CSS contains the CSS property in the body section attached with element is known as inline CSS. This kind of style is specified within an HTML tag using style attribute.
<html>
<head>
<title>Inline CSS</title>
</head>
<body>
<p style = "color:#009900;
font-size:50px;
font-style:italic;
text-align:center;">
KBN COLLGE</p>
</body>
</html>
Internal or Embedded CSS: This can be used when a single HTML document must be styled uniquely. The CSS rule set should be within the HTML file in the head section i.e the CSS is embedded within the HTML file
<html>
<head>
<title>Internal CSS</title>
<style>
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
.geeks {
font-style:bold;
font-size:20px;
}
</style>
</head>
<body>
<div class = "main">
<div class ="GFG">KBN COLLEGE</div>
<div class ="geeks">A computer science portal for students</p>
</div>
</body>
</html>
External CSS: External CSS contains separate CSS file which contains only style property with the help of tag attributes (For example class, id, heading, … etc). CSS property written in a separate file with .css extension and should be linked to the HTML document using link tag. This means that for each element, style can be set only once and that will be applied across web pages.
Css file
kbn.css
body {
background-color:powderblue;
}
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
#geeks {
font-style:bold;
font-size:20px;
}
Below is the HTML file that is making use of the created external style sheet
link tag is used to link the external style sheet with the html webpage.
href attribute is used to specify the location of the external style sheet file.
htmlfile
<html>
<head>
<link rel="stylesheet" href="kbn.css"/>
</head>
<body>
<div class = "main">
<div class ="GFG">KBNCOLLEGE</div>
<div id ="geeks">A computer science portal for geeks</p>
</div>
</body>
</html>
<html>
<head>
<title>Inline CSS</title>
</head>
<body>
<p style = "color:#009900;
font-size:50px;
font-style:italic;
text-align:center;">
KBN COLLGE</p>
</body>
</html>
Internal or Embedded CSS: This can be used when a single HTML document must be styled uniquely. The CSS rule set should be within the HTML file in the head section i.e the CSS is embedded within the HTML file
<html>
<head>
<title>Internal CSS</title>
<style>
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
.geeks {
font-style:bold;
font-size:20px;
}
</style>
</head>
<body>
<div class = "main">
<div class ="GFG">KBN COLLEGE</div>
<div class ="geeks">A computer science portal for students</p>
</div>
</body>
</html>
External CSS: External CSS contains separate CSS file which contains only style property with the help of tag attributes (For example class, id, heading, … etc). CSS property written in a separate file with .css extension and should be linked to the HTML document using link tag. This means that for each element, style can be set only once and that will be applied across web pages.
Css file
kbn.css
body {
background-color:powderblue;
}
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
#geeks {
font-style:bold;
font-size:20px;
}
Below is the HTML file that is making use of the created external style sheet
link tag is used to link the external style sheet with the html webpage.
href attribute is used to specify the location of the external style sheet file.
htmlfile
<html>
<head>
<link rel="stylesheet" href="kbn.css"/>
</head>
<body>
<div class = "main">
<div class ="GFG">KBNCOLLEGE</div>
<div id ="geeks">A computer science portal for geeks</p>
</div>
</body>
</html>
Comments
Post a Comment