CSS Basics: by R.A. Sheikh
CSS Basics: by R.A. Sheikh
By
R.A. Sheikh
Cascading Style Sheets
It is considered to be made up of
HTML
Cascading Style Sheets (CSS)
Scripting language
All three of these components are linked via
Document Object Model (DOM)
DOM is the interface that allows scripting
languages to access the content, style, and
structure of the web documents and change
them dynamically
Tools of DHTML
HTML
Partitions and Organizes the content
CSS
- Defines the Presentation of the content
Scripting - JavaScript, JScript, VBScript
Adds interactivity to the page
DOM- Document Object Model
Defines what and how elements are exposed
for script access
Main points of CSS
SELECTOR { DECLARATION }
CSS – Terminology…
Declaration has two parts:
HI {color : green }
property : Value
• In general:
• Element(s) {Property1:Value;
Property2:Value;}
• Eg.: H1, B {color:olive; background:yellow; font-
family: arial, courier }
CSS-Adding styles to web pages
Four ways
Embed a style sheet within HTML
document
Link to an external stylesheet from the
HTML document
Add styles inline in the HTML document
Importing style sheets
CSS-Embed a style sheet
All stylesheet information lies at the top of
the HTML code (in the head portion)
Eg:
<HTML>
<STYLE TYPE=“text/css”>
<!—H1 {color: green; font-family: impact}-- >
</STYLE>
<HEAD>
<BODY> . . .
CSS-Link to an external style sheet
An externally defined stylesheet is used as a style
template that can be applied to a number of pages
A text file (with ext .css) contains the stylesheet rules
to be applied to a page (or set of pages)
Eg. A file named ‘mystyles.css’
Methods:
A method typically executes an action which acts
upon the object by which it is owned
Example: Alert
Events:
Used to trap actions related to its owning object
Typically, these actions are caused by the user
Example: when the user clicks on a submit button
Using <span> tag
Span tag play an important role in style sheets. In body of
the document, <span> … </span> tag is used to set
boundaries of the rule’s styling specification.
For eg.
<html>
<head> <style type=“text/css”>
P{font-size:12pt, text-align:justify}
.que {color:brown; font-style:italic}
.ans {color:red}
.big {font-size:25pt; color:red} </style> </head>
<body><body>
<p class=“que”>this <span class=“big” >style sheet </span>
class </p>
<p class=“ans”> style sheet class used in paragraph</p>
</body>