Unit 1 Notes
Unit 1 Notes
HTML (HyperText Markup Language) was created by Tim Berners-Lee in 1991. It is the
standard markup language used to create web pages. HTML has evolved through various
versions:
- HTML5: Modern version with support for multimedia, semantic elements, and APIs.
**Example:**
```html
<!DOCTYPE html>
<html>
<body><h1>Hello World</h1></body>
</html>
```
```html
<!DOCTYPE html>
<html>
<head><title>Example Page</title></head>
<body><p>This is a paragraph.</p></body>
</html>
```
**Theory:**
- Paragraphs: `<p>`
**Example:**
```html
<h1>Main Heading</h1>
```
1.4 Images
Images are added using `<img>` tag with `src` and `alt` attributes.
**Example:**
```html
```
1.5 Lists
**Example:**
```html
<ol>
<li>First Item</li>
<li>Second Item</li>
</ol>
<ul>
<li>Bullet Item</li>
</ul>
```
1.6 Tables
**Example:**
```html
<table border="1">
<tr><th>Name</th><th>Age</th></tr>
<tr><td>John</td><td>25</td></tr>
</table>
```
1.7 Forms
**Example:**
```html
<form>
</form>
```
1.8 Frames
Used to divide the browser window into multiple sections, each displaying a different HTML
document. Deprecated in HTML5.
**Example:**
```html
<frameset cols="50%,50%">
<frame src="left.html">
<frame src="right.html">
</frameset>
```
**Example:**
```html
</video>
```
CSS -
1. Introduction to CSS
CSS (Cascading Style Sheets) is used to style HTML elements. It separates content (HTML)
from presentation (CSS), allowing web pages to be styled efficiently.
**Syntax:**
```css
selector {
property: value;
```
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: blue;
font-size: 24px;
</style>
</head>
<body>
<h1>Welcome to CSS</h1>
</body>
</html>
```
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
p { color: green; }
</style>
</head>
<body>
<p>Internal CSS</p>
</body>
</html>
```
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
h1, h2 {
color: navy;
p{
font-family: Arial;
font-size: 14px;
line-height: 1.5;
</style>
</head>
<body>
<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<p>This is a paragraph.</p>
</body>
</html>
```
4. Selector Forms
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
* { margin: 0; }
p { color: black; }
</style>
</head>
<body>
<div id="main">
<p>Text inside div</p>
</div>
</body>
</html>
```
---
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #f0f0f0;
color: #333;
font-size: 16px;
</style>
</head>
<body>
</body>
</html>
```
6. Font Properties
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
p{
font-size: 14px;
font-weight: bold;
font-style: italic;
</style>
</head>
<body>
</body>
</html>
```
7. List Properties
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
ul { list-style-type: square; }
ol { list-style-type: upper-roman; }
</style>
</head>
<body>
<ul><li>Item A</li></ul>
<ol><li>Item 1</li></ol>
</body>
</html>
```
8. Color
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightgray;
color: darkblue;
</style>
</head>
<body>
</body>
</html>
```
9. Alignment of Text
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
h1 { text-align: center; }
td { vertical-align: middle; }
</style>
</head>
<body>
<h1>Centered Heading</h1>
</body>
</html>
```
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
</body>
</html>
```
- Rounded corners
- Shadows
- Animations
- Media Queries
- Flexbox
**Example Program:**
```html
<!DOCTYPE html>
<html>
<head>
<style>
.box {
border-radius: 10px;
width: 200px;
height: 100px;
background-color: lightblue;
.box {
background-color: yellow;
</style>
</head>
<body>
</body>
</html>
```
---
JavaScript
1. Object Orientation and JavaScript
// Constructor Function
this.name = name;
this.age = age;
Person.prototype.greet = function() {
};
class Car {
constructor(make, model) {
this.make = make;
this.model = model;
getDetails() {
```
```js
// Variable declarations
let x = 10;
const PI = 3.14;
// Conditional
if (x > 5) {
} else {
console.log("x is 5 or less");
// Loop
console.log(i);
```
- **Operations:**
```js
let a = 5;
let b = 3;
let sum = a + b; // 8
```
- **Input Methods:**
**Example – I/O:**
```js
document.write(`<h2>Welcome, ${name}</h2>`);
alert("This is an alert!");
}
```
Below is one HTML + JavaScript program that demonstrates **all** of the above topics in a
single script.
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
/* 1. Object Orientation */
this.name = name;
this.age = age;
User.prototype.greet = function() {
};
/* Create Object */
/* 4. Output */
document.write(`<p>${user.greet()}</p>`);
if (isAdult) {
document.write("<p>Status: Adult</p>");
} else {
document.write("<p>Status: Minor</p>");
alert(user.greet());
</script>
</body>
</html>
```
2. **Syntax & Control Flow:** Uses `prompt`, `if...else`, and logs to console.
3. **Primitives & Operations:** Handles number conversion, comparison, and boolean logic.
4. **I/O:** Uses `document.write`, `console.log`, `confirm`, and `alert` to interact with the
user.