skip to Main Content

I have very many buttons on very many pages like this:

<button>Some text</button>

Is it possible to set in CSS that no one of them submits its form unless I set it explicitly?

I do NOT want to disable buttons, I want them not to submit the form.

2

Answers


  1. Chosen as BEST ANSWER

    Very sadly, but I figured out that it's not possible. CSS is changing style of elements, not their functionality.


  2. Honestly, I’d say this belongs to your JS, and not your CSS. You would just need to select all your buttons, and switch the "disable" attribute on all of them.

    If you REALLY wish to do something with css, you could probably create a pseudo element that will cover your button by default. Something like this:

    button {
      position: relative;
      z-index: -1;
    }
    button::before {
      position: absolute;
      top: 0;
      left: 0;
      content: '';
      width: 100%;
      height: 100%;
      z-index: 2;
    }
    

    You could then create an extra class for the buttons that should not be covered, which would either change z-index to 2, or which add a display:none to the pseudo element.

    But again, I would not see the point and strongly recommend you to go the JS way

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search