PS02CINT51 Web Programming Unit 1 - Part 2
PS02CINT51 Web Programming Unit 1 - Part 2
Unit 2
CSS3 selectors
In CSS, other aspect of selectors are patterns used to select the element(s) you want to
<head>
<style>
.test
{
.
.
.
}
</style>
Page 1 of 16
</head>
<body>
<p class=”test”> Hello Students </p>
</body>
CSS3 classes
<head>
<style>
.test
background-color: yellow;
</style>
</head>
<body>
</body>
Page 2 of 16
CSS3 precedence rules
When the browser needs to resolve what styles to apply to a given HTML element, it
uses a set of CSS precedence rules. Given these rules, the browser can determine
3. Sequence of declaration.
Note, that CSS precedence happens at CSS property level. Thus, if two CSS rules
target the same HTML element, and the first CSS rule takes precedence over the
second, then all CSS properties specified in the first CSS rule takes precedence over
the CSS properties declared in the second rule. However, if the second CSS rule
contains CSS properties that are not specified in the first CSS rule, then these are still
applied. The CSS rules are combined - not overriding each other.
Page 3 of 16
Introduction to Media Query
Media queries are a feature of CSS that enable webpage content to adapt to different
screen sizes and resolutions. They are a fundamental part of responsive web design
and are used to customize the appearance of websites for multiple devices.
<style>
body {
background-color: lightgreen;
body {
background-color: lightblue;
</style>
Page 4 of 16
Introduction to JavaScript
// Add examples of Simple if, else.. if and for loop (Which shows it
// is easy to learn).
JavaScript Syntax
Syntax:
<script>
</script>
Page 5 of 16
Types of JavaScript and their syntax:
<script type=”text/javascript”>
</script>
OR
<script language=”javascript”>
</script>
Page 6 of 16
2. External JavaScript:
</script>
OR
</script>
Page 7 of 16
Variables
- Declaration
e.g.
var studnum;
var a = 5;
var b = 7;
var res = a + b;
- Data type
Page 8 of 16
Boolean – Represents Boolean (True / False)
Strings
e.g.
Numbers
e.g.
value at a time.
variable.
e.g.
Operators
1. Assignment operator ( = ):
var a = 25;
Page 10 of 16
var res = a + b;
var a = “abc”;
var b = “def”;
var c = a + b;
if ( a==b )
}
Page 11 of 16
Functions
commas.
Syntax:
Function Definition:
function fun_nm( )
// function body
Function call:
fun_nm( );
Page 12 of 16
Variable Scope
1. Local scope:
2. Global scope:
Event Handling
on these events.
JavaScript.
Page 13 of 16
// Add appropriate examples.
JavaScript
function test1( )
var x = document.forms[“form”][“num”].value;
if (x === “ “)
return false;
Page 14 of 16
HTML form
</form>
Window
History Location
Document
Form
Different
Controls
Page 15 of 16
// Write different examples (e.g. all types of validations, Popup
Built-in objects
Page 16 of 16