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

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:-

تعليقات

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

Uncontrolled form input in React-JS

  Uncontrolled form input in React-JS? If we want to take input from users without any separate event handling then we can uncontrolled the data binding technique. The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles the form data. Here, the HTML elements maintain their own state that will be updated when the input value changes. To write an uncontrolled component, you need to use a ref to get form values from the DOM. In other words, there is no need to write an event handler for every state update. You can use a ref to access the input field value of the form from the DOM. Example of Uncontrolled Form Input:- import React from "react" ; export class Info extends React . Component {     constructor ( props )     {         super ( props );         this . fun = this . fun . bind ( this ); //event method binding         this . input = React . createRef ();...

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...

JDBC using JSP and Servlet

JDBC means Java Database Connectivity ,It is intermediates from Application to database. JDBC has different type of divers and provides to communicate from database server. JDBC contain four different type of approach to communicate with Database Type 1:- JDBC-ODBC Driver Type2:- JDBC Vendor specific Type3 :- JDBC Network Specific Type4:- JDBC Client-Server based Driver  or JAVA thin driver:- Mostly we prefer Type 4 type of Driver to communicate with database server. Step for JDBC:- 1  Create Database using MYSQL ,ORACLE ,MS-SQL or any other database 2   Create Table using database server 3   Create Form according to database table 4  Submit Form and get form data into servlet 5  write JDBC Code:-     5.1)   import package    import java.sql.*     5.2)  Add JDBC Driver according to database ide tools     5.3)  call driver in program         ...