CSS Learning #17
CSS is used to control and format the style of a web document or web pages in a simple and easy way.
WHAT IS CSS?
CSS stands for Cascading Style Sheets.
Once the styles are defined in CSS, it can be used by any page that references the CSS file. and if we want to change any format or style of several pages we have to change only CSS file at once.
CSS is a method to beautify html pages. it is a power of beautification that is apply on simple HTML pages.
Using style sheet language, you can add effects or animations to your website, animations like different buttons effects, spinners or loaders and animated backgrounds.
CSS Syntax:
The declaration block contains one or more declarations in braces separated by semi-colons. Each declaration itself contains a property, a colon (:), and a value.
There are three different ways to implement CSS Styles:
Inline
External
Internal
Internal CSS
we can also called embedded CSS to internal CSS. the style of CSS is specified between opening<head> and closing </head> tags. internal CSS affects all the elements in the body section.
located in the <head> opening tag in HTML page.
Example:
<html>
<head>
<body>
{
h1{
}
</style>
</head>
<h1> Heading Tag </h1>
</body>
</html>
we can also use class and ID selectors in this style sheet.
Example:
.class{
}
#id{
Since we'll only add the code within the same HTML file. we don't need to upload multiple files.
one disadvantage is that, adding the code to the HTML file can increase the page's size and loading time.
External CSS
External style sheet is the most and best used method to add styles to a web pages. you can link your web pages to an external .css file, .css file can be created by any text editor in your device for example Notepad++.
with this type of CSS you can change the entire website's look by changing just one file.
you have to include a reference to the external style sheet file inside the <link> element, inside the head section of each HTML page.
<link rel="stylesheet" type="text/css" href="style.css">
Inline CSS
An inline style used to apply a special style for a single html element. it can use for styling a single page, used for limited section.
inline style is the simple way to apply style to html elements. you have to add styles directly to html elements.
<body>
</body>
CSS Comments
Comments are used in CSS to explain a code or to make changes during development. the code doesn't execute which is commented.
comment starts with /* and ends with */:
/* This is a single-line comment */
p{
Add comments wherever you want:
p{
color: blue; /* This is a single-line comment */
Multiple line Comments:
p{
color: blue; /* paragraph tag,
Comments
Post a Comment
Thanks you
for comment and your suggestion