100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

Web Programming/Development Course Notes

Rating
-
Sold
-
Pages
12
Uploaded on
25-02-2023
Written in
2022/2023

Are you looking to learn web development but don't know where to start? Do you struggle to keep track of all the different languages, frameworks, and tools that are used in web development? Look no further! Our web development notes have got you covered. Our comprehensive notes cover all the essential concepts and technologies used in web development, including HTML, CSS, JavaScript, PHP, SQL, and more. Whether you're a beginner just starting out or an experienced developer looking to brush up on your skills, our notes are the perfect resource for you. Our notes are organized in an easy-to-follow format, with clear explanations and practical examples that will help you to understand each concept and how to apply it in real-world scenarios. Plus, our notes are constantly updated to ensure that you have access to the latest tools and technologies used in web development. Don't waste any more time struggling to learn web development on your own. Get our web development notes today and take your skills to the next level! With our notes, you'll have everything you need to become a successful web developer and build amazing websites and web applications.

Show more Read less
Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
February 25, 2023
Number of pages
12
Written in
2022/2023
Type
Class notes
Professor(s)
Unknown
Contains
All classes

Subjects

Content preview

Chapter 8. Style Sheets
Table of Contents

Objectives .............................................................................................................................................. 1
8.1 Introduction to Style Sheets ......................................................................................................... 1
8.1.1 Advantages of Style Sheets.............................................................................................. 1
8.1.2 Disadvantages of Style Sheets ......................................................................................... 2
8.2 CSS .............................................................................................................................................. 2
8.3 Important Note About Rules ........................................................................................................ 3
8.4 In-line Styles ................................................................................................................................ 3
8.5 Embedded Style sheets................................................................................................................. 4
8.6 Imported Style Sheet .................................................................................................................... 4
8.7 Classes ......................................................................................................................................... 5
8.8 Cascading Style Sheets ................................................................................................................ 6
8.9 Review Question .......................................................................................................................... 8
8.9.1 Review Question 1: Reflection on Style Sheets ............................................................... 8
8.10 Discussions and Answers ......................................................................................................... 8
8.10.1 Discussion of Exercise 1 ................................................................................................ 8
8.10.2 Answer to Exercise 2 ..................................................................................................... 9
8.10.3 Answer to Exercise 3 ..................................................................................................... 9
8.10.4 Solutions to Exercise 4 .................................................................................................. 9
8.10.5 Solutions to Exercise 5 ................................................................................................ 10
8.10.6 Solutions to Activity 1 ................................................................................................. 11
8.10.7 Discussion of Review Question 1 ................................................................................ 12



Objectives
At the end of this chapter you will be able to:
• Explain the advantages and disadvantage of using stylesheets;
• Use CSS to create web pages.


8.1 Introduction to Style Sheets
There is no format to follow for teaching the aesthetics of style - most people, though, can recognise something
that follows a classical design. But some things can be said about the style of a website. For instance, when
Web pages belong to the same website, each page should have a consistent look in order to provide familiarity
for the user.

Style sheets (sometimes referred to as templates) are used in desktop publishing to provide consistency when
formatting text. The format applied by the stylesheet could be to indent every first line of a paragraph by
2cm, insert a page break at the end of every chapter, and so on. Naturally, due to multimedia, Web pages
not only have to consider text formatting, but also visual and sound presentation, and various multimedia
formats in general. Before we continue, let us briefly discuss the advantages and disadvantages of using style
sheets.

8.1.1 Advantages of Style Sheets
1. Multiple Styles - A single document can be presented in multiple styles by using multiple style sheets.

2. Re-styling - The use of style sheets (which are separate to the HTML files) allows the quick re- styling of
any document, without modifying the original HTML.

, Style Sheets
3. Document maintenance - The ability to re-style many documents allows us to easily make changes to the
appearance of many Web pages without separately editing each one.

4. Consistency - Style sheets guarantee consistency throughout website.

5. Optimal file size - The smaller the files the faster the download. Using style sheets can help minimize
file sizes, since, for example, every < font > tag, is defined in one place in a style sheet, rather than in multiple
places in the HTML file.

6. Style and structure - When first developed, HTML was only concerned with document markup and not with
the document's formatting. This eventually changed, with more and more functionality being added to HTML to
allow for formatting. With the introduction of style sheets, the HTML document is again concerned only with
structural document markup — all formatting is now placed in the style sheet.

Exercise 1

Visit the UCT Computer Science Department website [http://www.cs.uct.ac.za] and suggest how the above
advantages of style sheets can be used. You can find some discussion on this at the end of this chapter.


8.1.2 Disadvantages of Style Sheets
1. Browser dependency - Style sheets format things slightly differently on different browsers.
Unfortunately, browsers have different support for HTML and style sheets. Newer browsers have largely
converged on HTML support so that HTML documents look the same across different browsers. The state
of style sheet support is somewhat worse, largely because style sheets are newer than HTML.

2. Old Browsers - Some very old browsers (such Netscape Navigator 2) do not support style sheets. All in all,
style sheets have only minor disadvantages, and should be used when developing websites.

To Do
Read up on style sheets on your text books. Can you see any advantages or disadvantages that have not been
presented here? Also use the Internet to find out more about the usage of style sheets. A good starting place is the
W3C's section on style sheets [http://www.w3.org/Style/].


8.2 CSS
The style sheet standard supported by modern browsers is called cascading style sheets, or CSS. CSS files contain a
set of rules for the formatting of HTML documents. An example is given below:

<html>
<head>
<title>UCT MSc IT Example 1 on style sheets</title>
<style>
BODY {

font-family : "times new roman;
margin-left : 20%;
margin-right: 20%;
text-align : justify;
background : ivory;
color : black;
}

P {
text-indent : 2cm;
}
</style>
</head>

A style sheet is a collection of rules that describe the format of the HTML tags. In the above example there are six
2
$20.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
arshshops24

Get to know the seller

Seller avatar
arshshops24 SAIT
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
12
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions