Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 33

Website Design &

Development
LESSON [5] –CSS - CASCADING  STYLE SHEETS

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Introduction
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?


◦ CSS is used to define styles for your web pages, including the design, layout and variations in display for
different devices and screen sizes. 

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Solved a Big Problem
◦ HTML was NEVER intended to contain tags for formatting a web page!
◦ HTML was created to describe the content of a web page, like:
◦ <h1>This is a heading</h1>
◦ <p>This is a paragraph.</p>
◦ When tags like <font>, and color attributes were added to the HTML 3.2
specification, it started a nightmare for web developers. Development of large
websites, where fonts and color information were added to every single page,
became a long and expensive process.
◦ To solve this problem, the World Wide Web Consortium (W3C) created CSS.
◦ CSS removed the style formatting from the HTML page!

CSS WEBSITE DESIGN & DEVELOPMENT


Advantages of CSS
◦CSS saves time − You can write CSS once and then reuse same sheet in multiple HTML
pages. You can define a style for each HTML element and apply it to as many Web pages
as you want.
◦Pages load faster − If you are using CSS, you do not need to write HTML tag attributes
every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag.
So less code means faster download times.
◦Easy maintenance − To make a global change, simply change the style, and all elements in
all the web pages will be updated automatically.
◦Superior styles to HTML − CSS has a much wider array of attributes than HTML, so you
can give a far better look to your HTML page in comparison to HTML attributes.
◦Multiple Device Compatibility − Style sheets allow content to be optimized for more than
one type of device. By using the same HTML document, different versions of a website
can be presented for handheld devices such as PDAs and cell phones or for printing.
◦Global web standards − Now HTML attributes are being deprecated and it is being
recommended to use CSS. So its a good idea to start using CSS in all the HTML pages to
make them compatible to future browsers.
◦Offline Browsing − CSS can store web applications locally with the help of an offline
catche. Using of this, we can view offline websites.The cache also ensures faster loading
and better overall performance of the website.
◦Platform Independence − The Script offer consistent platform independence and can
support latest browsers as well.
CSS WEBSITE DESIGN & DEVELOPMENT
CSS Selectors
◦ CSS selectors are used to "find" (or select) HTML
elements based on their element name, id, class,
attribute, and more.
◦ Type of selector:
◦ Element selector
◦ ID selector
◦ Class selector
◦ Grouping selector

CSS WEBSITE DESIGN & DEVELOPMENT


<html>
<head> <body>
<style>
p{ <h1>Element Selector</h1>
text-align: center; <p>Every paragraph will be affected by the style.</p>
color: red;
} <h1>ID Selector </h1>
#para1 { <p id="para1">Hello World!</p>
text-align: right;
color: green; <h1>Class Selector</h1>
} <h1 class="center">Red and center-aligned heading</h1>
.center { <p class="center">Red and center-aligned paragraph.</p>
text-align: left;
color: blue; <h1>Grouping Selectora</h1>
} <h4>Hello World!</h4>
<h2>Smaller heading!</h2>
h4,h2, p { <p>This is a paragraph.</p>
text-align: center;
color: purple; </body>
} </html>

</style>
</head>
CSS WEBSITE DESIGN & DEVELOPMENT
Three Ways to Insert CSS
External style sheet
Internal style sheet
Inline style

CSS WEBSITE DESIGN & DEVELOPMENT


External style sheet
With an external style sheet, you can change the look of an entire website by
changing just one file!
Each page must include a reference to the external style sheet file inside the
<link> element. The <link> element goes inside the <head> section:

HTML Sheet
Save this as name.htm

CSS sheet
(Save this as mystyle.css)

CSS WEBSITE DESIGN & DEVELOPMENT


Internal Style Sheet
An internal style sheet may be used if one single page has a unique style.
Internal styles are defined within the <style> element, inside the <head>
section of an HTML page:

CSS WEBSITE DESIGN & DEVELOPMENT


Inline Styles
An inline style may be used to apply a unique style for a single element.
To use inline styles, add the style attribute to the relevant element. The style
attribute can contain any CSS property.
The example below shows how to change the color and the left margin of a
<h1> element:

CSS WEBSITE DESIGN & DEVELOPMENT


Cascading Order
What style will be used when there is more than one style specified for an
HTML element?
Generally we can say that all the styles will "cascade" into a new "virtual" style
sheet by the following rules, where number one has the highest priority:
◦ Inline style (inside an HTML element)
◦ External and internal style sheets (in the head section)
◦ Browser default

So, an inline style (inside a specific HTML element) has the highest priority,
which means that it will override a style defined inside the <head> tag, or in an
external style sheet, or a browser default value.

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Backgrounds
CSS background properties:
◦ background-color –
body {
background-color: lightblue;
}
h1 {
background-color: green;
}
◦ background-image -
body {

background-image: url("background-wallpapers-34.jpg");

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Backgrounds
◦ background-repeat –
◦ background-repeat: repeat|repeat-x|repeat-y
body
{
background-repeat: repeat-x;
}
◦ background-position
◦ left top|left center|left bottom|right top|right center|right bottom|center top|center center
center bottom
body
{
background-position: right top;
}

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Borders

CSS WEBSITE DESIGN & DEVELOPMENT


CSS WEBSITE DESIGN & DEVELOPMENT
CSS Margins
Margin - Individual Sides
CSS has properties for specifying the margin
for each side of an element:
•margin-top
•margin-right
•margin-bottom
•margin-left

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Height and Width

CSS WEBSITE DESIGN & DEVELOPMENT


CSS format
Text Alignment

CSS WEBSITE DESIGN & DEVELOPMENT


Text Decoration

CSS WEBSITE DESIGN & DEVELOPMENT


Text Transformation

CSS WEBSITE DESIGN & DEVELOPMENT


Text Shadow

CSS WEBSITE DESIGN & DEVELOPMENT


Font Icons

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Links

Styling Links

CSS WEBSITE DESIGN & DEVELOPMENT


Background Color of the link

CSS WEBSITE DESIGN & DEVELOPMENT


Advanced - Link Buttons

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Tooltip
A tooltip is often used to specify extra information about something when the
user moves the mouse pointer over an element:

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Navigation Bar
Having easy-to-use navigation is important for any web site.
With CSS you can transform boring HTML menus into good-looking
navigation bars. Navigation Bar = List of Links

CSS WEBSITE DESIGN & DEVELOPMENT


Vertical Navigation Bar

CSS WEBSITE DESIGN & DEVELOPMENT


Horizontal Navigation Bar

CSS WEBSITE DESIGN & DEVELOPMENT


CSS Forms

CSS WEBSITE DESIGN & DEVELOPMENT


Code continues

CSS WEBSITE DESIGN & DEVELOPMENT


Design the following web page

CSS WEBSITE DESIGN & DEVELOPMENT


Any Question ?

The End..!!

CSS WEBSITE DESIGN & DEVELOPMENT

You might also like