All input tag in html

HTML Tag

To associate text with a specific element, we use the tag which sets a text label for it.

Syntax

The tag is empty, which means that the closing tag isn’t required. But in XHTML, the () tag must be closed ().

Example of the HTML tag:

html> html> head> title>Title of the document title> head> body> form action="/form/submit" method="get"> input type="email" name="user_email" placeholder="Enter your email" /> input type="submit" value="Submit" /> form> body> html>

Example of the HTML tag with the HTML tag:

html> html> head> title>Title of the document title> head> body> form action="/form/submit" method="get"> label>Your Name: label> input type="text" name="first_name" /> br/> br/> label>Your Surname: label> input type="text" name="last_name" /> br/> br/> label>Enter Your E-Mail: label> input type="email" name="user_email" /> br/> br/> input type="submit" value="Submit" /> form> body> html>

Result

input tag example

Attributes

The main attribute that determines the type of input field is type . If the attribute is missing, the default value is «text».

Читайте также:  Php unit test example

Values of the type attribute

Value Description
button Defines the active button.
checkbox Check the boxes (the user can select more than one of the options).
color Specifies a color palette (user can select color values in hexadecimal).
date Defines the input field for calendar date.
datetime Defines the input field for date and time.
datetime-local Defines the input field for date and time without a time zone.
e-mail Defines the input field for e-mail.
file Sets the control with the Browse button, clicking on which you can select and load the file.
hidden Defines a hidden input field. It is not visible to the user.
image Indicates that an image is used instead of a button to send data to the server. The path to the image is indicated by the src attribute. The alt attribute can also be used to specify alternative text, the height and width attributes to specify the height and width of the image.
month Defines the field of selecting a month, after which the data will be displayed as year-month (for example: 2018-07).
number Defines the input field for numbers.
password Defines a field for entering a password (the entered characters are displayed as asterisks, dots or other characters).
radio Creates radio button (when choosing one radio button all others will be disabled).
range Creates a slider to select numbers in the specified range. The default range is from 0 to 100. The range of numbers is specified by the min and max attributes.
reset Defines a button for resetting information.
search Creates a text field for search.
submit Creates a button of submitting the form data (“submit” button).
text Creates a single line text field.
time Specifies a numeric field for entering time in a 24-hour format (for example, 13:45).
url Creates an input field for URL.
week Creates a field for selecting the week, after which the data will be displayed as year-week (for example: 2018-W25).
Читайте также:  Как проверить работоспособность java

How to style tag?

Common properties to alter the visual weight/emphasis/size of text in tag:

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick.
  • CSS text-transform property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in tag:

  • CSS color property describes the color of the text content and text decorations.
  • CSS background-color property sets the background color of an element.

Text layout styles for tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for tag:

  • CSS text-shadow property adds shadow to text.
  • CSS text-align-last property sets the alignment of the last line of the text.
  • CSS line-height property specifies the height of a line.
  • CSS letter-spacing property defines the spaces between letters/characters in a text.
  • CSS word-spacing property sets the spacing between words.

Источник

HTML Tag

An HTML form with three input fields; two text fields and one submit button:

Definition and Usage

The tag specifies an input field where the user can enter data.

Читайте также:  Лабораторные работы java ооп

The element is the most important form element.

The element can be displayed in several ways, depending on the type attribute.

The different input types are as follows:

Look at the type attribute to see examples for each input type!

Tips and Notes

Browser Support

Attributes

Attribute Value Description
accept file_extension
audio/*
video/*
image/*
media_type
Specifies a filter for what file types the user can pick from the file input dialog box (only for type=»file»)
alt text Specifies an alternate text for images (only for type=»image»)
autocomplete on
off
Specifies whether an element should have autocomplete enabled
autofocus autofocus Specifies that an element should automatically get focus when the page loads
checked checked Specifies that an element should be pre-selected when the page loads (for type=»checkbox» or type=»radio»)
dirname inputname.dir Specifies that the text direction will be submitted
disabled disabled Specifies that an element should be disabled
form form_id Specifies the form the element belongs to
formaction URL Specifies the URL of the file that will process the input control when the form is submitted (for type=»submit» and type=»image»)
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server (for type=»submit» and type=»image»)
formmethod get
post
Defines the HTTP method for sending data to the action URL (for type=»submit» and type=»image»)
formnovalidate formnovalidate Defines that form elements should not be validated when submitted
formtarget _blank
_self
_parent
_top
framename
Specifies where to display the response that is received after submitting the form (for type=»submit» and type=»image»)
height pixels Specifies the height of an element (only for type=»image»)
list datalist_id Refers to a element that contains pre-defined options for an element
max number
date
Specifies the maximum value for an element
maxlength number Specifies the maximum number of characters allowed in an element
min number
date
Specifies a minimum value for an element
minlength number Specifies the minimum number of characters required in an element
multiple multiple Specifies that a user can enter more than one value in an element
name text Specifies the name of an element
pattern regexp Specifies a regular expression that an element’s value is checked against
placeholder text Specifies a short hint that describes the expected value of an element
readonly readonly Specifies that an input field is read-only
required required Specifies that an input field must be filled out before submitting the form
size number Specifies the width, in characters, of an element
src URL Specifies the URL of the image to use as a submit button (only for type=»image»)
step number
any
Specifies the interval between legal numbers in an input field
type button
checkbox
color
date
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
url
week
Specifies the type element to display
value text Specifies the value of an element
width pixels Specifies the width of an element (only for type=»image»)

Global Attributes

Event Attributes

  • Input Button Object
  • Input Checkbox Object
  • Input Color Object
  • Input Date Object
  • Input Datetime Object
  • Input DatetimeLocal Object
  • Input Email Object
  • Input FileUpload Object
  • Input Hidden Object
  • Input Image Object
  • Input Month Object
  • Input Number Object
  • Input Password Object
  • Input Range Object
  • Input Radio Object
  • Input Reset Object
  • Input Search Object
  • Input Submit Object
  • Input Text Object
  • Input Time Object
  • Input URL Object
  • Input Week Object

Источник

HTML Form Elements

This chapter describes all the different HTML form elements.

The HTML Elements

The HTML element can contain one or more of the following form elements:

The Element

One of the most used form element is the element.

The element can be displayed in several ways, depending on the type attribute.

Example

All the different values of the type attribute are covered in the next chapter: HTML Input Types.

The Element

The element defines a label for several form elements.

The element is useful for screen-reader users, because the screen-reader will read out loud the label when the user focus on the input element.

The element also help users who have difficulty clicking on very small regions (such as radio buttons or checkboxes) — because when the user clicks the text within the element, it toggles the radio button/checkbox.

The for attribute of the tag should be equal to the id attribute of the element to bind them together.

The Element

The element defines a drop-down list:

Example

The elements defines an option that can be selected.

By default, the first item in the drop-down list is selected.

To define a pre-selected option, add the selected attribute to the option:

Example

Visible Values:

Use the size attribute to specify the number of visible values:

Example

Allow Multiple Selections:

Use the multiple attribute to allow the user to select more than one value:

Example

The Element

The element defines a multi-line input field (a text area):

Example

The rows attribute specifies the visible number of lines in a text area.

The cols attribute specifies the visible width of a text area.

This is how the HTML code above will be displayed in a browser:

You can also define the size of the text area by using CSS:

Example

The Element

The element defines a clickable button:

Example

This is how the HTML code above will be displayed in a browser:

Note: Always specify the type attribute for the button element. Different browsers may use different default types for the button element.

The and Elements

The element is used to group related data in a form.

The element defines a caption for the element.

Example

This is how the HTML code above will be displayed in a browser:

The Element

The element specifies a list of pre-defined options for an element.

Users will see a drop-down list of the pre-defined options as they input data.

The list attribute of the element, must refer to the id attribute of the element.

Example

The Element

The element represents the result of a calculation (like one performed by a script).

Example

Perform a calculation and show the result in an element:

HTML Exercises

HTML Form Elements

Tag Description
Defines an HTML form for user input
Defines an input control
Defines a multiline input control (text area)
Defines a label for an element
Groups related elements in a form
Defines a caption for a element
Defines a drop-down list
Defines a group of related options in a drop-down list
Defines an option in a drop-down list
Defines a clickable button
Specifies a list of pre-defined options for input controls
Defines the result of a calculation

For a complete list of all available HTML tags, visit our HTML Tag Reference.

Источник

Оцените статью