التخطي إلى المحتوى الرئيسي

CSS Introduction,What is CSS,How to apply css in HTML



CSS:-  it means a cascading style sheet, it is used to provide a set of properties to design the HTML web page. Without using CSS, we can not best design, theme, and appearance on Web Page.HTML only provide a set of an element using HTML Tag but CSS provide properties to design HTML.
If we  want to provide backgroundcolor,backgroundimage,height,width,margin,padding,font-family,font-size,color,alignment then we use css.
History of CSS:-
CSS was first proposed by Håkon Wium Lie on October 10, 1994. At the time, Lie was working with Tim Berners-Lee at CERN. Style sheets have existed in one form or another since the beginnings of Standard Generalized Markup Language (SGML) in the 1980s, and CSS was developed to provide style sheets for the web.
Note:- If you did not read HTML then first read this article after that read this then you can easily understand the CSS concept.

Click to learn HTML




CSS has three different approaches to write it.
1) inline css:-  we can write css under HTML element similat to HTML property.
<p style="backhround-color:red;color:yellow;">dfdif yiud yfiudyfudyfidfy</p>
Example of Inline CSS:-
<html>
<head>
</head>
<body>
<div style="height:400px;border:2px solid blue;">
<p style="background-color: red;color:white;">Welcome in SCS</p>
<h1 style="color:orange">Welcome in Inline css </h1>
<input type="text" style="width: 400px;height: 30px;margin-left: 120px;margin-top: 50px;" />
</div>
</body>
</html>
Now I am creating a small front page using inline CSS, which contains the header, footer, and middle.
Complete Code 
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body style="margin:0px;">
<div style="height:100px;background-color:blue;">
  <h1 style="color:white;margin: 0px;">Computer Sales and Services Indore</h1>
</div>
<div style="height:500px;background-image: url('reg.jpg');background-size: cover;">
  <h1>Welcome in Shiva Concept Digital</h1>
<a href="http://shivaconceptsolution.com/digital" style="color:red;font-weight:bolder;">Click here</a>
</div>
<div style="height:200px;background-color:blue;">
<div style="float:left;height:180px;width:30%;margin-left: 10px;margin-top:10px;border:1px solid white;">
Part1
</div>
<div style="float:left;height:180px;width:30%;margin-left: 10px;margin-top:10px;border:1px solid white;">
Part2

</div>
<div style="float:left;height:180px;width:30%;margin-left: 10px;margin-top:10px;border:1px solid white;">
Part3
</div>
</div>
</body>
</html>
2) Internal CSS:-
  We will write CSS code under <head> section of HTML web page using <style> tag.
 This CSS contains two different blocks.
1)  Implicit block:-
   All predefined tags of HTML will be defined as an implicit block.
p
{
}
h1
{
}
img
{
}
2) Explicit block:-  this type of block will be created manually using .block and #block.
.block will be called by the class selector and #block will be called by id selector
.abc
{
     color:red;
    font-size:24px;
}

<div class="abc"></div>

#mno
{
     color:orange;
    background-color:yellow;
}
<div id="mno"></div>
#block will be used to define unique features on the web page because we can not use ID multiple items.
.block will be used to define repeated features on the web page, it can be called multiple times on a single web page.
A complete example of Internal CSS, create any .html file and write this code.
<!DOCTYPE html>
<html>
<head>
<title></title>

<style type="text/css">
*
{
margin: 0px;
}
        #header
        {
          height:100px;
          background-color:blue;
        }
        h1
        {
        color:white;
        margin: 0px;
        }
        #middle
        {
            height:500px;
            background-image: url('reg.jpg');
            background-size: cover;
        }

        #mid
        {
        height:200px;
        background-color:blue;
        }
        a
        {
        color:red;
        font-weight:bolder;
        }

        .part
        {
        float:left;
        height:180px;
        width:30%;
        margin-left: 10px;
        margin-top:10px;
        border:1px solid white;
        }
</style>
</head>
<body>
<div id="header">
  <h1>Computer Sales and Services Indore</h1>
</div>
<div id="middle">
  <h1>Welcome in Shiva Concept Digital</h1>
<a href="http://shivaconceptsolution.com/digital">Click here</a>
</div>
<div id="mid">
<div class="part">
Part1
</div>
<div class="part">
Part2
</div>
<div class="part">
Part3
</div>
</div>
</body>
</html>


External CSS:-  We will create a separate CSS file that can be used on multiple web pages.
We will create a .css extension file to implement external CSS.
Step1:-
Create .html file 
Step2nd:-
Create .css file
Step3rd:-
Link .css file under HTML Web page.
Code of Html file:-
<!DOCTYPE html>
<html>
<head>
<title></title>

<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="middle">
<div class="part"></div>
<div class="part"></div>
<div class="part"></div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Code of CSS File
*
{
margin: 0px;
}
body
{
background-color: lightblue;
}
#container
{ margin-left:50px;
margin-right: 50px;
}
#header
{
height: 100px;
background-color: darkblue;
}
#middle
{
height: 500px;
background-color: lightgray;
}
.part
{
   width:31.5%;
   height: 100%;
   border:1px solid red;
   margin-left: 20px;
   float:left;
}
#footer
{
height: 100px;
background-color: darkblue;
}
Now we create five web page application using HTML + CSS
1)   Create HTML file and define three section using <div>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="middle">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
2) Create a .css file under the same folder:
i have created .css file and named it style.css
*
{
margin: 0px;
}
#container
{
    }

#header
{
   height: 100px;
   background-color: #918484;
}
#middle
{
  height: 500px;
  background-color: #e65a5a;

}
#footer
{
height: 300px;
   background-color: #918484;

}
3)  Link style.css file under index.html file <head></head>

  <link rel="stylesheet" type="text/css" href="style.css">
4) Create five web page content to copy.

Download Code:-

تعليقات

المشاركات الشائعة من هذه المدونة

DSA in C# | Data Structure and Algorithm using C#

  DSA in C# |  Data Structure and Algorithm using C#: Lecture 1: Introduction to Data Structures and Algorithms (1 Hour) 1.1 What are Data Structures? Data Structures are ways to store and organize data so it can be used efficiently. Think of data structures as containers that hold data in a specific format. Types of Data Structures: Primitive Data Structures : These are basic structures built into the language. Example: int , float , char , bool in C#. Example : csharp int age = 25;  // 'age' stores an integer value. bool isStudent = true;  // 'isStudent' stores a boolean value. Non-Primitive Data Structures : These are more complex and are built using primitive types. They are divided into: Linear : Arrays, Lists, Queues, Stacks (data is arranged in a sequence). Non-Linear : Trees, Graphs (data is connected in more complex ways). Example : // Array is a simple linear data structure int[] number...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025

 Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025 Now a days most of the IT Company asked NODE JS Question mostly in interview. I am creating this article to provide help to all MERN Stack developer , who is in doubt that which type of question can be asked in MERN Stack  then they can learn from this article. I am Shiva Gautam,  I have 15 Years of experience in Multiple IT Technology, I am Founder of Shiva Concept Solution Best Programming Institute with 100% Job placement guarantee. for more information visit  Shiva Concept Solution 1. What is the MERN Stack? Answer : MERN Stack is a full-stack JavaScript framework using MongoDB (database), Express.js (backend framework), React (frontend library), and Node.js (server runtime). It’s popular for building fast, scalable web apps with one language—JavaScript. 2. What is MongoDB, and why use it in MERN? Answer : MongoDB is a NoSQL database that stores data in flexible, JSON-like documents. It...