Want to highlight button in HTML page

Hi everyone,

Can you please tell me if there is any syntax in HTML which works as “Enter”.Actually I want to highlight a button in such a way,if a user press the enter button in keyboard,corressponding HTML page button will be pressed. generally in a web page after filling a form we press the enter button to post the form. Is it possible by HTML coding?? means i don’t want to click the button in the web page,just press the enter button in keyboard.

Please give your valuable response…Thanking you…


In most browsers(maybe all ?) all links in a page will behave that way if they are active (e.g. tabbed through).

With javascript you can handle events like keypress which could do it for you.

<script type="text/javascript" charset="utf-8">
  window.onkeypress = function(event) {
  if (event.keyCode == 13) { // enter key pressed
    //do something
    window.location = 'someplace.html';

Perhaps a better way is to focus on a link in the page and use the default action of the enter key.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" charset="utf-8">
window.onkeydown = function(event) {
  if (event.keyCode == 13) { // enter key pressed
	<p><a id="linky" href="linky.html">linky linky</a></p>

Thanks a lot markbrown4 for your help…It is working now…

I hope you are not making a page that has a pretty picture or similar and just says hit enter to enter the site…

All that does is make the user visit two pages to use the site - the hit enter page and the real site. Why not just take them directly into the site by dumping any such page and making the page they go to on hitting enter your index page??? A barrier to entering the site is a barrier that makes people go away.

No John, I am talking about a page where user can fill up a form and submit the form by just pressing the enter button. It is not the 1st page or introductory page. It contains a genuine form. I appreciate your concern but it is not like that…

Thanking you…

If you have a form containing [COLOR="DarkSlateBlue"]<input type="submit">[/COLOR], when a user is typing in a form field and presses ‘Enter’, that will submit the form in pretty much all mainstream browsers. (Obviously this doesn’t work if they are in a textarea, where Enter just starts a new line, but it does the job on an ordinary input field).

This is one of the advantages of using a proper [COLOR="DarkSlateBlue"]<input type="submit">[/COLOR] rather than a Javascript submission.