-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter8.html
More file actions
87 lines (81 loc) · 2.51 KB
/
chapter8.html
File metadata and controls
87 lines (81 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chapter 8: HTML Advanced</title>
<link rel="stylesheet" href="style.css">
<style>
.chapter-header { font-size: 1.8rem; margin-bottom: 25px; }
.tag-section { margin-bottom: 40px; }
.item { margin-bottom: 25px; padding: 10px; border: 1px solid #ccc; border-radius: 6px; background:#fafafa; }
.item-row { display: flex; flex-wrap: wrap; gap: 20px; }
.item-row .item { flex: 1 1 calc(33% - 20px); min-width: 250px; }
.caption { font-size: 0.85rem; color: #555; margin-top: 5px; }
textarea { width: 100%; }
</style>
</head>
<body>
<h2 class="chapter-header" id="heading">Chapter 8: HTML Advanced</h2>
<!-- Data URIs -->
<div class="tag-section">
<h3> Data URIs</h3>
<div class="item">
<textarea name="input" cols="30" rows="3">Change this text and click the download link</textarea>
<br>
<a href="javascript:void(0)" download="data.txt">Download Text</a>
<script>
var input = document.querySelector("textarea[name='input']");
var download = document.querySelector("a[download]");
input.addEventListener("input", updateDownloadHref, false);
updateDownloadHref();
function updateDownloadHref() {
var text = input.value;
download.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(text));
}
</script>
<div class="caption">Data URI Example (Download Text)</div>
</div>
</div>
<!-- Block & Inline Elements -->
<div class="tag-section">
<h3> Block Elements</h3>
<div class="item-row">
<div class="item">
<p>This is a <p> block element</p>
<div class="caption">Block elements occupy full width</div>
</div>
<div class="item">
<div>This is a <div> block element</div>
<div class="caption">Block element example</div>
</div>
</div>
<h3> Inline Elements</h3>
<div class="item-row">
<div class="item">
<span>This is an inline <span></span>
<div class="caption">Inline elements occupy only needed width</div>
</div>
<div class="item">
<b>This is bold inline text</b>
<div class="caption">Inline element example</div>
</div>
</div>
<h3> Inline-block Elements</h3>
<div class="item-row">
<div class="item">
<button>Button</button>
<div class="caption"><button> behaves inline-block</div>
</div>
<div class="item">
<input type="text" placeholder="Input field">
<div class="caption"><input> behaves inline-block</div>
</div>
<div class="item">
<textarea placeholder="Textarea"></textarea>
<div class="caption"><textarea> inline-block example</div>
</div>
</div>
</div>
</body>
</html>