Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Why is WAVE throwing an "empty button" error when there's a type attribute specified?

+2
−0

Running the WAVE browser extension on a site, I'm getting an "Empty button" error on a search submit box:

Page with a search box opened. A red WAVE error is showing under the search submit icon, and an explanation of the error and the relevant HTML code are visible on the page, both provided below.

A <button> element is present that contains no text content (or alternative text), or an <input type="submit">, <input type="button">, or <input type="reset"> has an empty or missing value attribute.

The HTML that's highlighted as being responsible for this error shows as this, including a "type=" attribute:

<button type="submit" class="button is-filled is-outlined">
<i class="fa fa-search"></i>
</button>

The source code in Ruby for this element is this:

  <%= form_tag search_path, method: :get, role: 'search' do %>
    <div class="grid is-nowrap">
        <%= search_field_tag :search, params[:search], class: 'form-element' %>
        <div class="h-m-1">
          <%= button_tag type: :submit, class: 'button is-filled is-outlined', name: nil do %>
            <i class="fa fa-search"></i>
          <% end %>
        </div>
    </div>
  <% end %>

On a development instance running on localhost, I tried adding input_type: :submit to the button_tag, which results in input_type="submit" being added to the HTML, but I'm still getting the same WAVE error.

Why is WAVE giving me this error even though there is a type attribute (or input_type attribute) specified, and how can I resolve it?

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+1
−0

Let's take a look at what WAVE is telling us.

A <button> element is present that contains no text content (or alternative text), or an <input type="submit">, <input type="button">, or <input type="reset"> has an empty or missing value attribute.

The HTML that's highlighted as being responsible for this error shows as this, including a "type=" attribute:

<button type="submit" class="button is-filled is-outlined">
<i class="fa fa-search"></i>
</button>

Like WAVE says, the button has

  • No text content (the only content is an empty <i> element)
  • No alt text
  • No value attribute

To fix this issue, add one or more of these.

Since you're using Font Awesome, I'll refer you Font Awesome's guidelines on accessibility with icons.

Icons Used as Semantic Elements

If your icons have semantic meaning, you'll need to manually add a few things so that your icon is appropriately accessible:

Web Fonts Implementations

  1. Add an aria-hidden="true" attribute to the icon.
  2. Provide a text alternative inside a <span> (or similar) element that is a sibling to the icon.
  3. Include appropriate CSS to visually hide the element while keeping it accessible to assisitive technologies.
  4. Include appropriate CSS to visually hide the element while keeping it accessible to assisitive technologies.

Following the example there, you could change it to the following to make it more accessible:

<button type="submit" class="button is-filled is-outlined">
    <i aria-hidden="true" class="fa fa-search"></i>
    <span class="fa-sr-only">Submit search</span>
</button>
History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

There already is a "type" specified, and when I added an "input type", WAVE still threw the error. Wh... (2 comments)

Sign up to answer this question »