form target - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:form

Introduction

The default behavior is to replace the page with the response from server after the form has been submitted.

You can change this behavior by using the target attribute on the form element.

This attribute works in the same way as the target attribute on the a element.

Values for the target Attribute of the form Element

AttributeDescription
_blank Opens the server response in a new window (or tab)
_parent Opens the server response in the parent frameset
_self Opens the server response in the current window (which is the default behavior)
_top Opens the server response in the full body of the window.
<frame> Opens the server response in the specified frame

Each of these values represents a browsing context.

The following code shows the target attribute applied to a form element.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form target="_blank" method="post" action="http://example.com/form"> 
         <input autocomplete="on" name="fave"> 
         <input name="name"> 
         <button>Submit Vote</button> 
      </form>  
   </body><!-- w ww .j  a v a  2 s  . c om-->
</html>

Related Tutorials