इंटरनेट के ज़माने में किसी को मुबारकबाद देने के कई मेथड है। यह वेबसाइट भी आपको एक मेथड प्रोवाइड करता है , जिसको प्रयोग कर के आप किसी को भी विश कर सकते है। इसके लिए आपको टेक्सटबॉक्स में नाम लिखना है जिसे आप मुबारकबाद देना चाहते है, फिर आप फेसबुक या व्हाट्सप्प के माध्यम से शेयर कर सकते है.
There are many ways to congratulate someone in the age of the Internet. This website also provides you with a method, using which you can wish anyone. For this, you have to write the name in the textbox which you want to congratulate, then you can share it through Facebook or Whatsapp.
CSS stands for Cascading Style Sheets. It is used to make HTML web pages attractive and beautiful.
CSS controls the design, colour, font, size, spacing, background and layout of a webpage.
Uses of CSS:
There are three types of CSS:
Inline CSS is written directly inside an HTML tag using the style attribute.
Example:
<html>
<body>
<h1 style="color: red;">Welcome to CSS</h1>
<p style="font-size: 20px;">
This is a paragraph.
</p>
</body>
</html>
Explanation: Here, the heading colour is red and paragraph text size is 20px.
Internal CSS is written inside the <style> tag in the <head> section of an HTML document.
Example:
<html>
<head>
<style>
h1 {
color: blue;
}
p {
font-size: 18px;
color: green;
}
</style>
</head>
<body>
<h1>Welcome to CSS</h1>
<p>This is a paragraph.</p>
</body>
</html>
Explanation: Here, the heading colour is blue and paragraph colour is green.
External CSS is written in a separate .css file and connected to an HTML file using the <link> tag.
HTML File (index.html):
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Welcome to CSS</h1>
<p>This is my website.</p>
</body>
</html>
CSS File (style.css):
h1 {
color: red;
}
p {
color: blue;
font-size: 20px;
}
Explanation: The design is written in a separate CSS file called style.css.
Difference between three types of CSS:
| Inline CSS | Internal CSS | External CSS |
|---|---|---|
| Written inside HTML tag. | Written inside <style> tag. | Written in separate CSS file. |
| Used for one element. | Used for one webpage. | Used for multiple webpages. |
Uses style attribute. | Uses <style> tag. | Uses <link> tag. |
CSS selectors are used to select HTML elements and apply styles to them.
There are three common types of selectors:
An element selector selects HTML elements by their tag name.
Example:
p {
color: red;
font-size: 18px;
}
<p>This is first paragraph.</p>
<p>This is second paragraph.</p>
Explanation: Both paragraphs will have red colour and 18px font size.
A class selector is used to apply the same style to multiple HTML elements.
It starts with a dot (.).
Example:
<html>
<head>
<style>
.heading {
color: blue;
font-size: 25px;
}
</style>
</head>
<body>
<h1 class="heading">Welcome</h1>
<p class="heading">Hello Students</p>
</body>
</html>
Explanation: Both elements with the class name heading will have blue colour and 25px font size.
An ID selector is used to apply style to a particular HTML element.
It starts with a hash (#).
Example:
<html>
<head>
<style>
#box {
color: white;
background-color: green;
}
</style>
</head>
<body>
<h1 id="box">Welcome to CSS</h1>
</body>
</html>
Explanation: The heading with ID box will have white text and a green background.
Difference between Element, Class and ID Selector:
| Selector | Symbol | Purpose |
|---|---|---|
| Element | No symbol | Selects all elements of a particular tag. |
| Class | . | Selects elements with the same class. |
| ID | # | Selects an element with a particular ID. |
CSS properties are used to define the appearance and design of HTML elements.
For example, colour, font size, background, margin, padding and border are CSS properties.
Margin is the space outside an HTML element. It creates distance between two elements.
Example:
div {
margin: 20px;
}
Explanation: It creates 20px space outside the DIV element.
Padding is the space between the content and the border of an element.
Example:
div {
padding: 15px;
}
Explanation: It creates 15px space inside the element around its content.
Border is the line around an HTML element. We can change its colour, width and style.
Example:
div {
border: 2px solid red;
}
Explanation: It creates a 2px solid red border around the DIV element.
The color property is used to change the colour of text.
Example:
p {
color: blue;
}
Explanation: It changes the paragraph text colour to blue.
We can also use background-color to change the background colour.
body {
background-color: lightyellow;
}
Difference between Margin and Padding:
DIV stands for Division. It is an HTML tag used to create a section or container on a webpage.
It helps to group different HTML elements together.
We can apply CSS styles to a DIV using an ID selector.
Example:
<html>
<head>
<style>
#mybox {
width: 300px;
height: 150px;
background-color: lightblue;
border: 3px solid red;
padding: 20px;
margin: 30px;
}
</style>
</head>
<body>
<div id="mybox">
<h2>Welcome to CSS</h2>
<p>This is my first DIV box.</p>
</div>
</body>
</html>
Explanation:
#mybox selects the DIV using its ID.width sets the width of the DIV.height sets the height of the DIV.background-color sets the background colour.border creates a red border.padding creates space inside the DIV.margin creates space outside the DIV.Output: A light blue box with a red border containing a heading and paragraph.
A grouping selector is used when we want to apply the same CSS style to multiple HTML elements.
We separate the element names using commas (,).
Example:
<html>
<head>
<style>
h1, h2, p {
color: blue;
font-family: Arial;
}
</style>
</head>
<body>
<h1>Welcome</h1>
<h2>Learn CSS</h2>
<p>This is a paragraph.</p>
</body>
</html>
Explanation:
h1, h2 and p are grouped together.Advantage: It reduces repeated CSS code and saves time.
The universal selector is used to select all HTML elements on a webpage.
It is represented by the star symbol (*).
Example:
<html>
<head>
<style>
* {
color: red;
font-family: Arial;
}
</style>
</head>
<body>
<h1>Welcome to CSS</h1>
<p>This is a paragraph.</p>
<h2>Thank You</h2>
</body>
</html>
Explanation:
* selects all HTML elements.Advantage: It is useful when we want to apply common styles to the whole webpage.
Difference between Grouping and Universal Selector:
| Grouping Selector | Universal Selector |
|---|---|
| Selects multiple specified elements. | Selects all elements. |
Uses comma (,). | Uses star (*). |
Example: h1, p | Example: * |
Block elements are HTML elements that start on a new line and generally occupy the full available width of their parent container.
Examples of block elements:
<div><p><h1><h2><section>CSS is used with block elements to control the layout and appearance of a webpage.
CSS can control:
<html>
<head>
<style>
div {
width: 400px;
background-color: lightblue;
border: 2px solid blue;
padding: 20px;
margin: 20px;
}
p {
color: red;
font-size: 18px;
background-color: lightyellow;
padding: 10px;
}
</style>
</head>
<body>
<div>
<h2>My Website</h2>
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
</div>
</body>
</html>
CSS helps to control the position, size, colour, spacing and design of block elements. DIV is mainly used as a container, while P is used to display paragraphs.
| Topic | Remember |
|---|---|
| CSS | Cascading Style Sheets |
| Inline CSS | Uses style attribute |
| Internal CSS | Uses <style> tag |
| External CSS | Uses .css file |
| Element Selector | p { } |
| Class Selector | .name { } |
| ID Selector | #name { } |
| Grouping Selector | h1, p { } |
| Universal Selector | * { } |
| DIV | Creates a container |
| Margin | Space outside border |
| Padding | Space inside border |
| Border | Line around element |
| Color | Changes text colour |
Exam Preparation Tip
For each question, write the definition first, then explain the points and give one example program. This will make your answers easy to understand and well-presented in the examination.
AWS, PHP, Server Security, Laravel, Opencart, Drupal, Android Application Development, SEO Service, Digital Marketing Service, Social Website, E commerce Website
