The Navigator Object

The navigator object contains information about the browser. Note: There is no public standard that applies to the navigator object, but all major browsers support it. Navigator Object Properties Property Description appCodeName Returns the code name of the browser appName Returns the name of the browser appVersion Returns the version information of the browser cookieEnabled Determines […]

HTML DOM Bold Object

Bold Object The Bold object represents an HTML <b> element. Access a Bold Object You can access a <b> element by using getElementById(): Example var x = document.getElementById(“myB”); Try it Yourself » Create a Bold Object You can create a <b> element by using the document.createElement() method: Example var x = document.createElement(“B”); Try it Yourself » Standard […]

HTML DOM Textarea Object

Textarea Object The Textarea object represents an HTML <textarea> element. Access a Textarea Object You can access a <textarea> element by using getElementById(): Example var x = document.getElementById(“myTextarea”); Try it Yourself » Tip: You can also access a <textarea> element by searching through the elements collection of a form. Create a Textarea Object You can create a <textarea> element […]

HTML DOM Mark Object

Mark Object  The Mark Object is new in HTML5. The Mark object represents an HTML <mark> element. Note: The <mark> element is not supported in Internet Explorer 8 and earlier versions. Access a Mark Object You can access a <mark> element by using getElementById(): Example var x = document.getElementById(“myMark”); Try it Yourself » Create a Mark Object […]

HTML DOM Label Object

Label Object The Label object represents an HTML <label> element. Access a Label Object You can access a <label> element by using getElementById(): Example var x = document.getElementById(“myLabel”); Try it Yourself » Create a Label Object You can create a <label> element by using the document.createElement() method: Example var x = document.createElement(“LABEL”); Try it Yourself » Label […]

HTML <input> step Attribute

Example An HTML form with an input field with a specified legal number intervals: <form action=”/action_page.php”> <input type=”number” name=”points” step=”3″> <input type=”submit”> </form> Try it Yourself » Definition and Usage The step attribute specifies the legal number intervals for an <input> element. Example: if step=”3″, legal numbers could be -3, 0, 3, 6, etc. Tip: The step attribute can be used […]

HTML <input> src Attribute

Example An HTML form with an image that represents the submit button: <form action=”/action_page.php”> First name: <input type=”text” name=”fname”><br> <input type=”image” src=”submit.gif” alt=”Submit”> </form> Try it Yourself » Definition and Usage The src attribute specifies the URL of the image to use as a submit button. Note: The src attribute is required for <input type=”image”>, and can only be used with <input type=”image”>. […]

HTML <input> size Attribute

Example An HTML form with two input fields with a width of 35 and 4 characters: <form action=”/action_page.php”> Email: <input type=”text” name=”email” size=”35″><br> PIN: <input type=”text” name=”pin” maxlength=”4″ size=”4″><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The size attribute specifies the visible width, in characters, of an <input> element. Note: The size attribute works with the following input types: text, search, tel, url, email, […]

HTML <input> required Attribute

Example An HTML form with a required input field: <form action=”/action_page.php”> Username: <input type=”text” name=”usrname” required> <input type=”submit”> </form> Try it Yourself » Definition and Usage The required attribute is a boolean attribute. When present, it specifies that an input field must be filled out before submitting the form. Note: The required attribute works with the following input types: text, search, url, […]

HTML <input> readonly Attribute

Example An HTML form with a read-only input field: <form action=”/action_page.php”> Country: <input type=”text” name=”country” value=”Norway” readonly><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The readonly attribute is a boolean attribute. When present, it specifies that an input field is read-only. A read-only input field cannot be modified (however, a user can tab to it, highlight it, and copy […]

HTML <input> placeholder Attribute

Example Two input fields with a placeholder text: <form action=”/action_page.php”> <input type=”text” name=”fname” placeholder=”First name”><br> <input type=”text” name=”lname” placeholder=”Last name”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed […]

HTML <input> pattern Attribute

Example An HTML form with an input field that can contain only three letters (no numbers or special characters): <form action=”/action_page.php”> Country code: <input type=”text” name=”country_code” pattern=”[A-Za-z]{3}” title=”Three letter country code”> <input type=”submit”> </form> Try it Yourself » More “Try it Yourself” examples below. Definition and Usage The pattern attribute specifies a regular expression that the <input> element’s value is checked […]

HTML <input> name Attribute

Example An HTML form with three input fields; two text fields and one submit button: <form action=”/action_page.php”> Name: <input type=”text” name=”fullname”><br> Email: <input type=”text” name=”email”><br> <input type=”submit” value=”Submit”> </form> Try it Yourself » Definition and Usage The name attribute specifies the name of an <input> element. The name attribute is used to reference elements in a JavaScript, or to reference form data after a […]

HTML <input> multiple Attribute

Example A file upload field that accepts multiple values: <form action=”/action_page.php”> Select images: <input type=”file” name=”img” multiple> <input type=”submit”> </form> Try it Yourself » Definition and Usage The multiple attribute is a boolean attribute. When present, it specifies that the user is allowed to enter more than one value in the <input> element. Note: The multiple attribute works with the following input […]

HTML <input> value Attribute

Example An HTML form with initial (default) values: <form action=”/action_page.php”> First name: <input type=”text” name=”fname” value=”John”><br> Last name: <input type=”text” name=”lname” value=”Doe”><br> <input type=”submit” value=”Submit form”> </form> Try it Yourself » Definition and Usage The value attribute specifies the value of an <input> element. The value attribute is used differently for different input types: For “button”, “reset”, and “submit” – it defines the text on the […]

HTML <input> width Attribute

Example Define an image as the submit button, with height and width attributes: <form action=”/action_page.php”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”image” src=”img_submit.gif” alt=”Submit” width=”48″ height=”48″> </form> Try it Yourself » Definition and Usage The width attribute specifies the width of the <input> element. Note: The width attribute is used only with <input type=”image”>. Tip: Always specify both the height and width attributes for […]

HTML <input> max Attribute

Example Use of the min and max attributes: <form action=”/action_page.php”> Enter a date before 1980-01-01: <input type=”date” name=”bday” max=”1979-12-31″> Enter a date after 2000-01-01: <input type=”date” name=”bday” min=”2000-01-02″> Quantity (between 1 and 5): <input type=”number” name=”quantity” min=”1″ max=”5″> <input type=”submit”> </form> Try it Yourself » Definition and Usage The max attribute specifies the maximum value for an <input> element. Tip: Use the max attribute together with the min attribute to […]

HTML <input> min Attribute

Example Use of the min and max attributes: <form action=”/action_page.php”> Enter a date before 1980-01-01: <input type=”date” name=”bday” max=”1979-12-31″> Enter a date after 2000-01-01: <input type=”date” name=”bday” min=”2000-01-02″> Quantity (between 1 and 5): <input type=”number” name=”quantity” min=”1″ max=”5″> <input type=”submit”> </form> Try it Yourself » Definition and Usage The min attribute specifies the minimum value for an <input> element. Tip: Use the min attribute together with the max attribute to […]

HTML <input> list Attribute

Example An <input> element with pre-defined values in a <datalist>: <input list=”browsers”> <datalist id=”browsers”> <option value=”Internet Explorer”> <option value=”Firefox”> <option value=”Google Chrome”> <option value=”Opera”> <option value=”Safari”> </datalist> Try it Yourself » Definition and Usage The list attribute refers to a <datalist> element that contains pre-defined options for an <input> element. Browser Support The numbers in the table specify the first browser version that fully […]

HTML <input> height Attribute

Example Define an image as the submit button, with height and width attributes: <form action=”/action_page.php”> First name: <input type=”text” name=”fname”><br> Last name: <input type=”text” name=”lname”><br> <input type=”image” src=”img_submit.gif” alt=”Submit” width=”48″ height=”48″> </form> Try it Yourself » Definition and Usage The height attribute specifies the height of the <input> element. Note: The height attribute is used only with <input type=”image”>. Tip: Always specify both the height and width attributes for […]