Can I ignore some website element when navigating using the tab key?









up vote
32
down vote

favorite
1












As question really. I have an input box on my page that I would like to ignore when navigating using the keyboard tab key.



I'm using this input box as a simple bot honeytrap and positioning it off the page, so at the moment when using the tab key, it looks to the user as though nothing has focus when they tab to this element.










share|improve this question

















  • 1




    Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
    – Rex M
    May 3 '10 at 12:38






  • 2




    @Rex — which achieves … what? It will still be in the tab order.
    – Quentin
    May 3 '10 at 12:43










  • @David and also set the tabindex.
    – Rex M
    May 3 '10 at 13:06














up vote
32
down vote

favorite
1












As question really. I have an input box on my page that I would like to ignore when navigating using the keyboard tab key.



I'm using this input box as a simple bot honeytrap and positioning it off the page, so at the moment when using the tab key, it looks to the user as though nothing has focus when they tab to this element.










share|improve this question

















  • 1




    Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
    – Rex M
    May 3 '10 at 12:38






  • 2




    @Rex — which achieves … what? It will still be in the tab order.
    – Quentin
    May 3 '10 at 12:43










  • @David and also set the tabindex.
    – Rex M
    May 3 '10 at 13:06












up vote
32
down vote

favorite
1









up vote
32
down vote

favorite
1






1





As question really. I have an input box on my page that I would like to ignore when navigating using the keyboard tab key.



I'm using this input box as a simple bot honeytrap and positioning it off the page, so at the moment when using the tab key, it looks to the user as though nothing has focus when they tab to this element.










share|improve this question













As question really. I have an input box on my page that I would like to ignore when navigating using the keyboard tab key.



I'm using this input box as a simple bot honeytrap and positioning it off the page, so at the moment when using the tab key, it looks to the user as though nothing has focus when they tab to this element.







html css accessibility tabindex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 3 '10 at 12:31









thor

71321224




71321224







  • 1




    Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
    – Rex M
    May 3 '10 at 12:38






  • 2




    @Rex — which achieves … what? It will still be in the tab order.
    – Quentin
    May 3 '10 at 12:43










  • @David and also set the tabindex.
    – Rex M
    May 3 '10 at 13:06












  • 1




    Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
    – Rex M
    May 3 '10 at 12:38






  • 2




    @Rex — which achieves … what? It will still be in the tab order.
    – Quentin
    May 3 '10 at 12:43










  • @David and also set the tabindex.
    – Rex M
    May 3 '10 at 13:06







1




1




Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
– Rex M
May 3 '10 at 12:38




Instead of positioning it off the page, place it in a normal-looking spot and cover it up with another element.
– Rex M
May 3 '10 at 12:38




2




2




@Rex — which achieves … what? It will still be in the tab order.
– Quentin
May 3 '10 at 12:43




@Rex — which achieves … what? It will still be in the tab order.
– Quentin
May 3 '10 at 12:43












@David and also set the tabindex.
– Rex M
May 3 '10 at 13:06




@David and also set the tabindex.
– Rex M
May 3 '10 at 13:06












4 Answers
4






active

oldest

votes

















up vote
46
down vote



accepted










You can set the tabindex="-1" on this element so it's ignored in the tad order. 0 tells the browser to figure out the tab order on it's own, -1 tells the browser to ignore it.






share|improve this answer



























    up vote
    12
    down vote













    You can use tabindex attribute to define order in which the tab key should cycle through elements. If you set tabindex="-1" the element will be skipped.



    More info is available here http://www.webcheatsheet.com/HTML/controll_tab_order.php for example.



    UPDATE
    changed tabindex="0" to "-1" based on comments






    share|improve this answer






















    • This is only part of the solution, though - the focus will end up at the element at some point, just later.
      – Pekka 웃
      May 3 '10 at 12:38






    • 3




      This is incorrect: jsfiddle.net/6QuHc
      – Nick Craver
      May 3 '10 at 12:38










    • Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
      – Quentin
      May 3 '10 at 12:39










    • +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
      – Pekka 웃
      May 3 '10 at 13:44










    • Setting tabindex to -1 works great - thanks for all the replies and suggestions.
      – thor
      May 5 '10 at 10:12

















    up vote
    1
    down vote













    display: none it instead.






    share|improve this answer




















    • True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
      – Konerak
      May 3 '10 at 12:37






    • 1




      That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
      – Quentin
      May 3 '10 at 12:40










    • I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
      – thor
      May 5 '10 at 10:10

















    up vote
    0
    down vote













    I used workaround disabled flag on my input element, because no user input is wanted in my case :)



    Example with 3 inputs:






    .container 
    display: flex;
    flex-direction: column;

    input
    width: 200px;
    margin-bottom: 10px;

    <div class="container">
    <input placeholder="Not disabled"/>
    <input placeholder="Disabled - skipped by tab" disabled/>
    <input placeholder="Not disabled"/>
    </div>





    Hope it works well for somebody <3 - Chrome, Edge, Firefox and also "pseudo" browser IE tested.






    share|improve this answer




















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2757973%2fcan-i-ignore-some-website-element-when-navigating-using-the-tab-key%23new-answer', 'question_page');

      );

      Post as a guest






























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      46
      down vote



      accepted










      You can set the tabindex="-1" on this element so it's ignored in the tad order. 0 tells the browser to figure out the tab order on it's own, -1 tells the browser to ignore it.






      share|improve this answer
























        up vote
        46
        down vote



        accepted










        You can set the tabindex="-1" on this element so it's ignored in the tad order. 0 tells the browser to figure out the tab order on it's own, -1 tells the browser to ignore it.






        share|improve this answer






















          up vote
          46
          down vote



          accepted







          up vote
          46
          down vote



          accepted






          You can set the tabindex="-1" on this element so it's ignored in the tad order. 0 tells the browser to figure out the tab order on it's own, -1 tells the browser to ignore it.






          share|improve this answer












          You can set the tabindex="-1" on this element so it's ignored in the tad order. 0 tells the browser to figure out the tab order on it's own, -1 tells the browser to ignore it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 3 '10 at 12:35









          Nick Craver

          525k11411891096




          525k11411891096






















              up vote
              12
              down vote













              You can use tabindex attribute to define order in which the tab key should cycle through elements. If you set tabindex="-1" the element will be skipped.



              More info is available here http://www.webcheatsheet.com/HTML/controll_tab_order.php for example.



              UPDATE
              changed tabindex="0" to "-1" based on comments






              share|improve this answer






















              • This is only part of the solution, though - the focus will end up at the element at some point, just later.
                – Pekka 웃
                May 3 '10 at 12:38






              • 3




                This is incorrect: jsfiddle.net/6QuHc
                – Nick Craver
                May 3 '10 at 12:38










              • Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
                – Quentin
                May 3 '10 at 12:39










              • +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
                – Pekka 웃
                May 3 '10 at 13:44










              • Setting tabindex to -1 works great - thanks for all the replies and suggestions.
                – thor
                May 5 '10 at 10:12














              up vote
              12
              down vote













              You can use tabindex attribute to define order in which the tab key should cycle through elements. If you set tabindex="-1" the element will be skipped.



              More info is available here http://www.webcheatsheet.com/HTML/controll_tab_order.php for example.



              UPDATE
              changed tabindex="0" to "-1" based on comments






              share|improve this answer






















              • This is only part of the solution, though - the focus will end up at the element at some point, just later.
                – Pekka 웃
                May 3 '10 at 12:38






              • 3




                This is incorrect: jsfiddle.net/6QuHc
                – Nick Craver
                May 3 '10 at 12:38










              • Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
                – Quentin
                May 3 '10 at 12:39










              • +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
                – Pekka 웃
                May 3 '10 at 13:44










              • Setting tabindex to -1 works great - thanks for all the replies and suggestions.
                – thor
                May 5 '10 at 10:12












              up vote
              12
              down vote










              up vote
              12
              down vote









              You can use tabindex attribute to define order in which the tab key should cycle through elements. If you set tabindex="-1" the element will be skipped.



              More info is available here http://www.webcheatsheet.com/HTML/controll_tab_order.php for example.



              UPDATE
              changed tabindex="0" to "-1" based on comments






              share|improve this answer














              You can use tabindex attribute to define order in which the tab key should cycle through elements. If you set tabindex="-1" the element will be skipped.



              More info is available here http://www.webcheatsheet.com/HTML/controll_tab_order.php for example.



              UPDATE
              changed tabindex="0" to "-1" based on comments







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited May 3 '10 at 12:58

























              answered May 3 '10 at 12:35









              michal kralik

              3,2901719




              3,2901719











              • This is only part of the solution, though - the focus will end up at the element at some point, just later.
                – Pekka 웃
                May 3 '10 at 12:38






              • 3




                This is incorrect: jsfiddle.net/6QuHc
                – Nick Craver
                May 3 '10 at 12:38










              • Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
                – Quentin
                May 3 '10 at 12:39










              • +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
                – Pekka 웃
                May 3 '10 at 13:44










              • Setting tabindex to -1 works great - thanks for all the replies and suggestions.
                – thor
                May 5 '10 at 10:12
















              • This is only part of the solution, though - the focus will end up at the element at some point, just later.
                – Pekka 웃
                May 3 '10 at 12:38






              • 3




                This is incorrect: jsfiddle.net/6QuHc
                – Nick Craver
                May 3 '10 at 12:38










              • Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
                – Quentin
                May 3 '10 at 12:39










              • +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
                – Pekka 웃
                May 3 '10 at 13:44










              • Setting tabindex to -1 works great - thanks for all the replies and suggestions.
                – thor
                May 5 '10 at 10:12















              This is only part of the solution, though - the focus will end up at the element at some point, just later.
              – Pekka 웃
              May 3 '10 at 12:38




              This is only part of the solution, though - the focus will end up at the element at some point, just later.
              – Pekka 웃
              May 3 '10 at 12:38




              3




              3




              This is incorrect: jsfiddle.net/6QuHc
              – Nick Craver
              May 3 '10 at 12:38




              This is incorrect: jsfiddle.net/6QuHc
              – Nick Craver
              May 3 '10 at 12:38












              Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
              – Quentin
              May 3 '10 at 12:39




              Tabindex=0 causes the element to be indexed using the normal conventions — w3.org/TR/html5/editing.html#negative-tabindex — it is used to add elements to the normal sequence that are not normally focusable, not to exclude them.
              – Quentin
              May 3 '10 at 12:39












              +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
              – Pekka 웃
              May 3 '10 at 13:44




              +1 tabindex='-1' indeed seems to work completely (with the input element coming out of the rotation). Deleting my answer with the JS approach.
              – Pekka 웃
              May 3 '10 at 13:44












              Setting tabindex to -1 works great - thanks for all the replies and suggestions.
              – thor
              May 5 '10 at 10:12




              Setting tabindex to -1 works great - thanks for all the replies and suggestions.
              – thor
              May 5 '10 at 10:12










              up vote
              1
              down vote













              display: none it instead.






              share|improve this answer




















              • True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
                – Konerak
                May 3 '10 at 12:37






              • 1




                That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
                – Quentin
                May 3 '10 at 12:40










              • I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
                – thor
                May 5 '10 at 10:10














              up vote
              1
              down vote













              display: none it instead.






              share|improve this answer




















              • True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
                – Konerak
                May 3 '10 at 12:37






              • 1




                That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
                – Quentin
                May 3 '10 at 12:40










              • I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
                – thor
                May 5 '10 at 10:10












              up vote
              1
              down vote










              up vote
              1
              down vote









              display: none it instead.






              share|improve this answer












              display: none it instead.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 3 '10 at 12:35









              Quentin

              630k718481018




              630k718481018











              • True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
                – Konerak
                May 3 '10 at 12:37






              • 1




                That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
                – Quentin
                May 3 '10 at 12:40










              • I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
                – thor
                May 5 '10 at 10:10
















              • True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
                – Konerak
                May 3 '10 at 12:37






              • 1




                That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
                – Quentin
                May 3 '10 at 12:40










              • I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
                – thor
                May 5 '10 at 10:10















              True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
              – Konerak
              May 3 '10 at 12:37




              True, but more advanced bots might check for that. (as they might for positioning it off the page, but that's real advanced).
              – Konerak
              May 3 '10 at 12:37




              1




              1




              That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
              – Quentin
              May 3 '10 at 12:40




              That is, hypothetically, possible. OTOH, if you off-screen it then screen readers will present it to real users.
              – Quentin
              May 3 '10 at 12:40












              I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
              – thor
              May 5 '10 at 10:10




              I did consider setting display to none but I was concerned that bots would find this much easier to check than positioning off-page, as Konerak stated. I'd already tested it with some screen-reading software and noticed it appears as an unlabelled text input box. This is obviously an issue but it's one I think we're going to have to live with for the time being and take another look at it later.
              – thor
              May 5 '10 at 10:10










              up vote
              0
              down vote













              I used workaround disabled flag on my input element, because no user input is wanted in my case :)



              Example with 3 inputs:






              .container 
              display: flex;
              flex-direction: column;

              input
              width: 200px;
              margin-bottom: 10px;

              <div class="container">
              <input placeholder="Not disabled"/>
              <input placeholder="Disabled - skipped by tab" disabled/>
              <input placeholder="Not disabled"/>
              </div>





              Hope it works well for somebody <3 - Chrome, Edge, Firefox and also "pseudo" browser IE tested.






              share|improve this answer
























                up vote
                0
                down vote













                I used workaround disabled flag on my input element, because no user input is wanted in my case :)



                Example with 3 inputs:






                .container 
                display: flex;
                flex-direction: column;

                input
                width: 200px;
                margin-bottom: 10px;

                <div class="container">
                <input placeholder="Not disabled"/>
                <input placeholder="Disabled - skipped by tab" disabled/>
                <input placeholder="Not disabled"/>
                </div>





                Hope it works well for somebody <3 - Chrome, Edge, Firefox and also "pseudo" browser IE tested.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I used workaround disabled flag on my input element, because no user input is wanted in my case :)



                  Example with 3 inputs:






                  .container 
                  display: flex;
                  flex-direction: column;

                  input
                  width: 200px;
                  margin-bottom: 10px;

                  <div class="container">
                  <input placeholder="Not disabled"/>
                  <input placeholder="Disabled - skipped by tab" disabled/>
                  <input placeholder="Not disabled"/>
                  </div>





                  Hope it works well for somebody <3 - Chrome, Edge, Firefox and also "pseudo" browser IE tested.






                  share|improve this answer












                  I used workaround disabled flag on my input element, because no user input is wanted in my case :)



                  Example with 3 inputs:






                  .container 
                  display: flex;
                  flex-direction: column;

                  input
                  width: 200px;
                  margin-bottom: 10px;

                  <div class="container">
                  <input placeholder="Not disabled"/>
                  <input placeholder="Disabled - skipped by tab" disabled/>
                  <input placeholder="Not disabled"/>
                  </div>





                  Hope it works well for somebody <3 - Chrome, Edge, Firefox and also "pseudo" browser IE tested.






                  .container 
                  display: flex;
                  flex-direction: column;

                  input
                  width: 200px;
                  margin-bottom: 10px;

                  <div class="container">
                  <input placeholder="Not disabled"/>
                  <input placeholder="Disabled - skipped by tab" disabled/>
                  <input placeholder="Not disabled"/>
                  </div>





                  .container 
                  display: flex;
                  flex-direction: column;

                  input
                  width: 200px;
                  margin-bottom: 10px;

                  <div class="container">
                  <input placeholder="Not disabled"/>
                  <input placeholder="Disabled - skipped by tab" disabled/>
                  <input placeholder="Not disabled"/>
                  </div>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  Hourglasser

                  438




                  438



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f2757973%2fcan-i-ignore-some-website-element-when-navigating-using-the-tab-key%23new-answer', 'question_page');

                      );

                      Post as a guest














































































                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo