CSC 104 HTML, Css and Javascript Notes
CSC 104 HTML, Css and Javascript Notes
HTML (HyperText Markup Language): is the standard language used for creating web pages and
web applications. HTML files can have either the .html or .htm file extension. The difference
between these two extensions is minimal and primarily historical.
Key Differences
1. File Extension Length: .html: This is a four-letter extension. .htm: This is a three-letter
extension.
2. Historical Context: The .htm extension was used in older operating systems like DOS,
which had a limitation of three-character file extensions^1^. This was necessary because
DOS could not handle four-letter extensions. Modern operating systems do not have this
limitation, so .html is more commonly used today
There are two main types of HTML based on how they are written and their evolution over
time:
Definition: Traditional HTML where the content is fixed (does not change unless
manually edited).
Example:
Example:
<script>
function changeText() {
}
</script>
1. <!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Welcome!</h1>
</body>
</html>
<!DOCTYPE html>
Example
<!DOCTYPE html>
<html>
<head>...</head>
<body>...</body>
</html>
<html>
Example:
<html lang="en">
<head>...</head>
<body>...</body>
</html>
<head>
o <script> (JavaScript)
Example:
<head>
<title>My Website</title>
<meta charset="UTF-8">
</head>
<body>
Purpose: Contains all visible content (text, images, links).
Example:
<body>
<h1>Welcome!</h1>
<p>This is a paragraph.</p>
</body>
<h1> to <h6>
Example:
<h1>Main Title</h1>
<h2>Subheading</h2>
<h3>Sub-subheading</h3>
<p>
Example:
<p>This is a paragraph.</p>
<br>
Example:
Example:
<p>Section 1</p>
<hr>
<p>Section 2</p>
<strong> vs <b>
<em> vs <i>
Key Attributes:
o href="URL" (link destination)
Example:
<img>
Key Attributes:
o alt="Description" (accessibility)
o width="200" (pixels)
Example:
Embeds a
<video> <video src="movie.mp4" controls></video>
video
Key Attributes:
loop (repeats)
5. List Tags
Example:
<ul>
<li>Coffee</li>
<li>Tea</li>
</ul>
Example:
<ol>
<li>First step</li>
<li>Second step</li>
</ol>
6. Form Tags
<form>
Key Attributes:
Example:
<button type="submit">Send</button>
</form>
<input>
Common Types:
o text (default)
Example:
7. Table Tags
Example:
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Alice</td>
<td>25</td>
</tr>
</table>
Tag Purpose
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<header>
<h1>Website Header</h1>
<nav>
<a href="/">Home</a>
</nav>
</header>
<section>
<h2>Section Title</h2>
<p>Paragraph text.</p>
</section>
<footer>© 2024</footer>
</body>
</html>
HTML)
<style>
p { color: red; }
</style>
``` | Small projects. |
| **External CSS** (`.css` file) |
```html
<link rel="stylesheet" href="styles.css">
``` | Best for large projects. |
Visualization:
Margin (10px)
Border (2px)
Padding (20px)
Content (200px width)
5. CSS Layouts
Flexbox (1D Layout)
Arranges items in rows or columns.
Key Properties:
.container {
display: flex;
justify-content: center; /* Horizontal alignment */
align-items: center; /* Vertical alignment */
gap: 10px; /* Space between items */
}
Animations
Custom keyframe animations.
@keyframes slide {
from { transform: translateX(0); }
to { transform: translateX(100px); }
}
.box {
animation: slide 2s infinite;
}
Category Properties