The Difference Between Anchors, Inputs and Buttons

By  on  
HTML5 Buttons

One of the things I love about CSS is how easy it is to make one element look like another. In the example above, the first element is an anchor, the second is a button and the third is an input. I've overridden the click behavior of all three so they do the same thing.

If all three elements look and behave the same, does it matter which one you use? In this article, I'll explain the difference between anchors, inputs and buttons, and I'll show you when to use each one.


The question of which element to use boils down to semantics, which is using markup that reflects the meaning of the content. Using semantic HTML makes your content explicit, which gives you better browser compatibility, accessibility and SEO.


Anchors (the <a> element) represent hyperlinks. What's a hyperlink? A hyperlink is a resource a person can navigate to or download in a browser. If you want to allow your user to move to a new page or download a file, then use an anchor.


An input (<input>) represents a data field. The type attribute tells the browser which type of data the input controls. There are five input types related to buttons.

  • <input type="submit">: This is the most common button input. It's a button that, when clicked, submits a form.
  • <input type="image">: Like an <input type="submit">, this input submits a form. However, it also takes a src attribute and is displayed as an image.
  • <input type="file">: This control is used to upload files and is shown as a label and a button. There's no good cross-browser way to style file inputs, so you'll usually set its display to hidden and use a second button to trigger it.
  • <input type="reset">: This is a button that resets a form.
  • <input type="button">: This is a button with no default behavior. You can use to it add non-standard behavior to a form using JavaScript.


The <button> element represents a button! Buttons do the same things as the inputs mentioned above. Buttons were introduced into HTML as an alternative to inputs that are much easier to style. Unlike inputs, a button's label is determined by its content. This means you can nest elements within a button, such as images, paragraphs, or headers. Buttons can also contain ::before and ::after pseudo-elements.

Like an input, a button has a type attribute. This attribute can be set to submit, reset or button and does the same thing as the input's type. By default, the type is submit. If you place a button in a form and don't set its type, when it's clicked it will submit that form! If you don't want this behavior, set the type to button.

One nifty feature of inputs and buttons is they support the disabled attribute. This makes it easy to turn them on and off. Sadly, anchors don't have this capability.

Which one?

So should you use an anchor, input or button? When you're navigating the user to a page or resource, use an anchor. Otherwise, both inputs and buttons are valid. Personally, I prefer to use inputs for submitting and resetting forms and buttons for custom behavior because I think it makes the intent clearer. However, the element you use is entirely up to you. Go nuts!

Landon Schropp

About Landon Schropp

Landon is a developer and entrepreneur based in Seattle. He's the author of Unraveling Flexbox, a book on how to create modern, responsive layouts in CSS. He's passionate about building simple apps people love to use.

Recent Features

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    Chris Coyier&#8217;s Favorite CodePen Demos

    David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...

Incredible Demos

  • By
    CSS Fixed Position Background Image

    Backgrounds have become an integral part of creating a web 2.0-esque website since gradients have become all the rage. If you think gradient backgrounds are too cliche, maybe a fixed position background would work for you? It does provide a neat inherent effect by...

  • By
    MooTools ASCII Art

    I didn't realize that I truly was a nerd until I could admit to myself that ASCII art was better than the pieces Picasso, Monet, or Van Gogh could create.  ASCII art is unmatched in its beauty, simplicity, and ... OK, well, I'm being ridiculous;  ASCII...


  1. To me it feels like a missed opportunity to not use the button to refer to, you know, an actual button! We already have a submit button.

  2. MaxArt

    So, what’s the best use for inputs of type “submit”, “reset” and “button”, if they are completely be superseded by buttons of the same type? I guess none, isn’t it?

  3. yes, concerns should be separated!

    1. It is weird to be able to middle-click on a “button” and be navigated to other tab/window.

    2. In case of bootstrap it is confusing to have “disabled button” created from , and also have additional JS logic to prevent it from actually being clicked.

  4. Nice David,

    Therefore, we must use the “button” for open the “hidden modal”. Sure? ;)

  5. Naveen

    I expected a little more on use cases of these three types like whether a link/page could be crawled via input/button or not? What are the SEO implications of all the three options? And many more details which I am not aware of!

  6. Paul Ferguson

    I may be wrong, but I heard there is also a distinction that a < button will fire on space bar while an < input type=submit can be called on enter.

  7. Steve

    It’s also worth noting that although the button element is likely the best element for a button we couldn’t use it widespread until IE8 (running in Standards Mode) was the minimum IE version we needed to support due to a long running IE bug where IE would submit the innerHTML when you clicked a button vs. the value attribute: In addition they also rendered horribly on Windows XP due to an OS bug: beyond that, button element is my choice for an actual button. ;-)

  8. i have a button that is acting as an anchor, but it will only work the first time the page is loaded. Any thoughts?

  9. Shweta Gupta

    I’m a beginner in learning HTML and I was really confused among the working of anchor, input and button tags. Now my doubts have cleared up. Great post!!!

  10. Aleks

    Thank you for good and concise explanation!

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!