HTML notes Part - 2
HTML notes Part - 2
HTML notes Part - 2
input tag
> input tag is used create a form elements
> these elements are used to take input/accept data from users.
> controls nothing but text field, button, radio button, file,
color, password, etc...
> input is un-paired tag and inline element
Syn:
<input attributes/>
Note: by default, input tag creates “text field”.
attributes of input tag:
type it reps which type of control you want to create.
if we are not specified by default it creates a textbox.
input type="text|hidden|password|number|button|reset|
submit|image|checkbox|radio|file|color|email|url|range|
date|time|datetime-local|month|week..."
name it represents name of control, used in server-side
programming (not unique)
id it represents id of control, used in client-side
programming (unique)
value it used to initialize input elements (default value)
readonly this attribute not allowed to change the value of
control
size this attribute specifies size of control (width of control)
disabled this attribute disabled the control
placeholder this attribute used to display prompting text
within the element
maxlength this attribute used to set max limit of data (no.of
chars)
required this attribute used to force the user to enter data
(mandatory field)
autofocus this attribute set's cursor position (Default
location)
tabindex this attribute controlling cursor movements (when
we r pressing tab key, where cursor is moving)
min this attribute used to set minimum limit of number
value (lower bound)
max this attribute used to set maximum limit of number
value (upper bound)
step this attribute used to specify incremental & decrement
value of number
text fields
>text field used for taking input(any type of data) from user or
text box allows us to type data.
>text fields are used for typing of username, first name,
pincode, phone, address etc...
>by using "input" tag we can create text fields
>user can type any no.of char's but single line, if u want to set a
limit use "maxlength" attribute.
>text field allows you to type data in 1 line.
Syn:
<input type="text" attributes/>
Note:
id used by client-side programming (javascript)
=> unique (duplicate id are not)
name used by server-side programming
(servlet/asp.net/php...)
=> either unique or not
hidden field
>an in-visible text field with default value is called a "hidden
field".
>hidden fields are used to send some information about
user/client to a server-side program without asking the user.
>to perform session tracking, we are using hidden fields.
>like normal text fields, hidden fields data is also sent to the
server when we click the submit button.
Syn:
<input type="hidden" name="NAME" value="VAL" attributes>
password control
> password is a text field but the data is not visible.
> it's used for accepting password, pin, cvv, otp, verification
code, passcode... from the user.
> password is displayed as * or dot
Syn:
<input type="password" attributes>
number control
>this control used to accept only numerical value (numbers
only) from user
>it prevents typing of alphabets, special chars (in some
browsers), except minus, dot and e alphabet.
>but some browser allows to type all these data but given error
while submitting form
> some browsers displaying number fields with
increment/decrement buttons
SYn:
<input type="number" attributes>
attributes:
min =>it rep starting value of number field (by default no min)
max =>it rep ending value of number field (by default no max)
step =>it rep increment/decrement value (by default +1/-1)
button control
reset button
>reset is one type of button, used for reset the html form/UI,
meaning it clears all values of form.
>reset button must be part of the "form" tag.
> these button values are not sent to the server.
Syn:
<input type="reset">
submit button
>submit is one type of button, used to submit/send the html
forms/page/UI to a server-side program.
>while submitting the html form, all input parameters (enter by
user), hidden parameter (by programmer) are prepared as a
"Query String"
ex:
https://www.redbus.in/search.aspx ? param-
name=value¶m-name=value &...
param-name => name of text box or name of password field
or name of button...
value => value of text box or value of password field or value
of button...
>outside the form, if we design anything that is not submitted
to the server and without name attribute also not submittable.
>submit button value also sent to server
Syn:
<input type="submit" value="VAL" attributes>
<form action=”search.jsp”>
public String getParameter(String param)
String st = request.getParameter(“t1”)
post
https://www.sitename.com/search.jsp
image button
> "image submit button" is used to submit a form to the server.
> when the user clicks on the image button, browser is
submitting data with x-co & y-co of image button
Syn:
<input type="image" src="filename" .../>
radio button
> RB is used to display two or more options to the user, but
allows the user to select any one of them.
SYn:
<input type="radio" attributes>
Note:
> all RBs should be created with the same name.
> "checked" attribute of RB makes the RB by default selected,
while opening the page.
file
>file used to upload or attachment
>we can upload or attach any type of file, but @time a only one
file
Syn <input type="file" attributes>
attributes:
multiple => it allows multiple to upload @time
accept => filtering type of file
Note:
while uploading file method should be "post" and enctype is
"multipart/form-data"
color
>used to select color by user, selected color we can apply on
any control using JS
Syn: <input type="color">
date & time controls
date
>used to create a date box (date picker/popup calendar), where
the user can select a date.
>the browser by default provides a built-in date picker.
Syn: <input type="date" attributes>
time
>used to create a time box, where the user can enter/select
time (in the form of hours, minutes and seconds)
Syn:<input type="time" attributes>
datetime
>used to create a date-cum-time control
Syn: <input type="datetime-local" attributes>
month
>used to create a month box, where the user can select a
month.
Syn: <input type="month" ...>
week
>used to create a week box, where the user can select a week.
Syn: <input type="week" ...>
email
>used to create an email textbox, where the user can enter a
valid email id only.
>it displays an error message automatically (built-in validation),
if the user enters other than email id (should contain @ and .).
Syn: <input type="email" attributes>
url
>used to create an url box, where the user can enter a valid url
for downloading files or playing videos.
>it displays an error message automatically (built-in validation),
if the user enters other than url.
Syn: <input type="url" attributes>
range
>used to create a slider bar, based on the specific range.
>this control req min value and max value, if we are not
specified then browser takes default values.
Syn: <input type="range" attributes>
attributes
min => it sets min value of slider
max => it sets max value of slider
step => it sets increment value
value => sets indicator init position
appearance: slider-vertical;
search
> used to create a search box, where the user can enter some
search text, it also displays a clear button to clear the text inside
the search box.
Syn: <input type="search" ... >
list box
>using the "select" tag we can create a list box.
>list box is used to display some options/items to the user and
allows the user to select any one of them (by default).
> "option" sub tag of "select" tag.
> "option" tag used to create/to add items/options to the list
box.
> "size" attribute used to change DDB into List box.
Syn:<select size="N" attributes>
<option attributes> Text </option>
<option> Text </option>
<option> Text </option>
...
</select>
Note: by default DDB is displaying 1st added option
attributes:
selected : this attribute of "option" tag, used to change default
selected option/item of DDB
multiple :it allows user to select more than one option @time
size :attribute used to change DDB into List box and no.of
options to display @time
option groups
> "optgroup" tag is used to group-up some options/items inside
the "select" tag.
> one "select" tag can contain many "optgroup" tags, the
"optgroup" tag contains many "options".
>its paired tag
> "optgroup" tag is the sub tag of "select" tag.
Syn:
<select>
<optgroup label="Text">
<option> ..</option>
<option> ..</option>
<option> ..</option>
</optgroup>
<optgroup>
...
</optgroup>
</select>
textarea
>"textarea" tag is used to create a multi-line textbox.
use case: comments, address, feedback, delivery instr, ...
>its paired tag& inline tag
>it creates a multi-line text box, with default sizes (2row & 20
col)
Syn: <textarea attributes>
init value
</textarea>
attributes:
rows : it rep no.of lines to display @time, if more lines of data
entered
automatically scrollbar is activated.
cols : it rep no.of chars per line
maxlength : it rep total no.of chars allowed in textbox.
Note: user can resize the textarea, at runtime in the browser.
progress bar
> "progress" tag is used to display the progress of a task.
> to move progress bar dynamically, we have to use "JS"
> it is a paired tag.
SYn: <progress attributes></progress>
attributes:
min max value
label
> when the user clicks on the label, the cursor will appear in the
associated control automatically.
Note: labels are not sent to the server while submitting the
form.
HTML5 tags
Datalist
Syn:<datalist attributes>
<option>text</option>
OR
<option value=”text”>
….
</datalist>
> details tag is the main tag and summary is the sub tag of
details tag.
Syn:
<details>
<summary>Short info</summary>
Detailed Information
</details>
header
Syn: <header>
</header>
nav
Syn: <nav>
place menus/links here
</nav>
section
Syn: <section>
</section>
footer
>"footer" tag represents the footer part of the web page, which
may include information of contact, faqs, location, copyrights,
etc...
>it doesn’t provide any styles by default; we have to apply
styles manually, using CSS.
Syn: <footer>
</footer>
aside
Syn: <aside>
</aside>
article
Syn: <article>
</article>
figure
figcaption
Syn: <figure>
Image
<figcaption> caption/text </figcaption>
</figure>
mark
bdi
base tag
this tag is used to specify a base URI or URL to use for all relative links
contained within an HTML document.
We can also specify how other links should open using the target
attribute.
Audio tag
Syn:-
<audio attributes></audio>
OR
<audio attributes>
</audio>
Attribute Definition
Video tag
Syn:-
<video attributes></video>
OR
<video attributes>
...
</video>
Attribute Definition
completion.
iframe
Syn:
<iframe attributes>
</iframe>
att:
width =>
height =>
> map tag used to explore internal details about par area of img
> map tag should link img tag ny using "usemap" attribute of
img
Syn:
<imgsrc="image">
<map name="">
...
</map>
Shape: it rep mapping area shape.
> circle
>rect
> poly
https://www.image-map.net/
marquee tag
Syn:
attributes:
direction => down, up, left (default), right
scrollamount => 6
meta
Refresh document:
<meta name="refresh" content="45">