-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample19.html
202 lines (185 loc) · 8.01 KB
/
example19.html
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Forms and Input Controls Tutorial</title>
<style>
/* Base Styles */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
background-color: #f9f9f9;
color: #333;
}
h1, h2 {
color: #444;
}
.section {
margin-bottom: 40px;
padding: 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 10px;
}
.code-example {
background-color: #f8f9fa;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
margin: 10px 0;
font-family: monospace;
}
img {
display: block;
margin: auto;
}
</style>
</head>
<body>
<h1>HTML Forms and Input Controls</h1>
<div class="section">
<h2>HTML Forms</h2>
<p>HTML forms are used to collect user input. Forms contain various input elements like text fields, checkboxes, and buttons.</p>
<div class="code-example">
<!-- HTML Form Example -->
<code>
<form action="/submit" method="post"> <br>
<label for="name">Name:</label> <br>
<input type="text" id="name" name="name"> <br><br>
<label for="email">Email:</label> <br>
<input type="email" id="email" name="email"> <br><br>
<button type="submit">Submit</button> <br>
</form>
</code>
</div>
<p><strong>Rendered Example:</strong></p>
<!-- Practical Example for HTML Form -->
<form action="/submit" method="post">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email"><br><br>
<button type="submit">Submit</button>
</form>
</div>
<div class="section">
<h2>HTML Input Types</h2>
<p>HTML input elements can have various types, such as <code>text</code>, <code>password</code>, <code>number</code>, and more, each with different behaviors and features.</p>
<div class="code-example">
<!-- HTML Input Types Example -->
<code>
<form> <br>
<input type="text" placeholder="Text"> <br>
<input type="password" placeholder="Password"> <br>
<input type="number" placeholder="Number"> <br>
</form>
</code>
</div>
<p><strong>Rendered Example:</strong></p>
<!-- Practical Example for HTML Input Types -->
<form>
<input type="text" placeholder="Text"><br><br>
<input type="password" placeholder="Password"><br><br>
<input type="number" placeholder="Number"><br><br>
</form>
</div>
<div class="section">
<h2>HTML Input Types (Extended)</h2>
<p>HTML offers many different input types that allow for specialized input controls. Below is a list of commonly used input types:</p>
<div class="code-example">
<!-- HTML Input Types Extended Example -->
<code>
<input type="button"><br>
<input type="checkbox"><br>
<input type="color"><br>
<input type="date"><br>
<input type="datetime-local"><br>
<input type="email"><br>
<input type="file"><br>
<input type="hidden"><br>
<input type="image"><br>
<input type="month"><br>
<input type="number"><br>
<input type="password"><br>
<input type="radio"><br>
<input type="range"><br>
<input type="reset"><br>
<input type="search"><br>
<input type="submit"><br>
<input type="tel"><br>
<input type="text"><br>
<input type="time"><br>
<input type="url"><br>
<input type="week"><br>
</code>
</div>
<p><strong>Rendered Example:</strong></p>
<!-- Practical Example for HTML Input Types Extended -->
<form>
<input type="button" value="Click me"><br><br>
<input type="checkbox"> Accept Terms<br><br>
<input type="color"><br><br>
<input type="date"><br><br>
<input type="email" placeholder="Enter your email"><br><br>
<input type="file"><br><br>
<input type="hidden" value="secret-data"><br><br>
<input type="image" src="submit.png" alt="Submit Image"><br><br>
<input type="month"><br><br>
<input type="password" placeholder="Enter Password"><br><br>
<input type="radio" name="gender"> Male<br>
<input type="radio" name="gender"> Female<br><br>
<input type="range" min="1" max="100" value="50"><br><br>
<input type="reset" value="Reset"><br><br>
<input type="search" placeholder="Search"><br><br>
<input type="submit" value="Submit"><br><br>
<input type="tel" placeholder="Phone Number"><br><br>
<input type="text" placeholder="Your Name"><br><br>
<input type="time"><br><br>
<input type="url" placeholder="Website URL"><br><br>
<input type="week"><br><br>
</form>
</div>
<div class="section">
<h2>HTML Input Attributes</h2>
<p>Various attributes can customize input elements, such as <code>required</code>, <code>maxlength</code>, and <code>min/max</code> to define value constraints.</p>
<div class="code-example">
<!-- HTML Input Attributes Example -->
<code>
<form> <br>
<input type="text" required placeholder="Required Input"> <br>
<input type="number" min="1" max="10" placeholder="1 to 10"> <br>
</form>
</code>
</div>
<p><strong>Rendered Example:</strong></p>
<!-- Practical Example for HTML Input Attributes -->
<form>
<input type="text" required placeholder="Required Input"><br><br>
<input type="number" min="1" max="10" placeholder="1 to 10"><br><br>
</form>
</div>
<div class="section">
<h2>Special Input Attributes</h2>
<p>The <code>readonly</code>, <code>disabled</code>, and <code>placeholder</code> attributes provide additional ways to modify input behavior.</p>
<div class="code-example">
<!-- Special Input Attributes Example -->
<code>
<form> <br>
<input type="text" placeholder="Editable Field"> <br>
<input type="text" readonly value="Read-Only Field"> <br>
<input type="text" disabled value="Disabled Field"> <br>
</form>
</code>
</div>
<p><strong>Rendered Example:</strong></p>
<!-- Practical Example for Special Input Attributes -->
<form>
<input type="text" placeholder="Editable Field"><br><br>
<input type="text" readonly value="Read-Only Field"><br><br>
<input type="text" disabled value="Disabled Field"><br><br>
</form>
</div>
</body>
</html>