Button in Html [Solved] | SoloLearn: Learn to code for FREE!

+3

Button in Html [Solved]

In Html - why we need to write <button type="button">text</button> What is wrong with <button>text</button> Tnx

9/22/2020 6:03:36 AM

Franko Stipanov

14 Answers

New Answer

+6

I also found a interesting topic about it .You can have a look at it: https://html.com/attributes/button-type/

+11

Yes, if there was an input tag, we could tell <Input type="submit" value= "Submit"/> If you using button tag Always specify the type attribute for a <button> element, to tell browsers what type of button it is. Otherwise: with button tag you can provide different functionality Like submit form and reset form etc.

+6

Don't know much about html .Maybe the reason is there are so much type of button: For example: <button type="submit"> submit</button> or <button type="reset">reset</button> https://www.w3schools.com/tags/att_button_type.asp

+5

Because system does not know what is the type of the input

+3

Type attribute with value button is not needed at all for interactive UI features. It is required only when you have a backend to listen to form submission and the button is used to submit or reset the form. https://www.w3schools.com/tags/att_button_type.asp

+3

1. <Button>submit</button> 2. <Input type="button" value="submit">

+2

+2

<button>text</button> Also works . But it is preferred to use a type attribute and you should also use.

+2

Franko Stipanov sir if u have got the answer write in the question name (solved) And mark the correct answer

+2

Ok sry Didn't know that

+2

<body> <form> <input type ="submit" value="submit" /> </form> </body>

+2

Declaring the type helps to its functionality

+1

Good practice is to use the type attribute . However one can dispense with it.

+1

Here type= button.. Is giving a signal to computer to type the text BUTTON on which user will click