Web Designing: Course:BCA Sem Course:BCA Semester:4th Subject: WD Faculty: Ms. Rubbina Topic:CSS
Web Designing: Course:BCA Sem Course:BCA Semester:4th Subject: WD Faculty: Ms. Rubbina Topic:CSS
Web Designing: Course:BCA Sem Course:BCA Semester:4th Subject: WD Faculty: Ms. Rubbina Topic:CSS
Course :BCA
Sem Course :BCA
Semester :4th
Subject : WD
Faculty: Ms. Rubbina
Topic :CSS
What is CSS
CSS stands for Cascading Style Sheets
CSS describes how HTML elements are to be
displayed on screen, paper, or in other media
CSS saves a lot of work. It can control the layout
of multiple web pages all at once
External stylesheets are stored in CSS files
Why Use CSS?
<h1>A heading</h1>
<p>A paragraph.</p>
</body>
Using CSS
CSS can be added to HTML documents in 3
ways:
Inline - by using the style attribute inside HTML
elements
Internal - by using a <style> element in
the <head> section
External - by using a <link> element to link to
an external CSS file
The most common way to add CSS, is to keep
the styles in external CSS files.
Inline CSS
An inline CSS is used to apply a unique style to a
single HTML element.
An inline CSS uses the style attribute of an HTML
element.
The following example sets the text color of
the <h1> element to blue, and the text color of
the <p> element to red:
Example
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
External CSS
An external style sheet is used to define the
style for many HTML pages.
The external style sheet can be written in
any text editor. The file must not contain
any HTML code, and must be saved with
a .css extension.
To use an external style sheet, add a link to
it in the <head> section of each HTML
page:
Example
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Here is what the "styles.css" file
looks like:
body {
background-color: powderblue;
}
h1 {
color: blue;
}
p{
color: red;
}
CSS Colors, Fonts and Sizes
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
CSS Border
The CSS border property defines a border around
an HTML element.
Example
Use of CSS border property:
p
{
border: 2px solid powderblue;
}
CSS Padding
The CSS padding property defines a padding
(space) between the text and the border.
Example
p
{
border: 2px solid powderblue;
padding: 30px;
}
CSS Margin
The CSS margin property defines a margin
(space) outside the border.
Example
p
{
border: 2px solid powderblue;
margin: 50px;
}