• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / Required attributes for HTML5 image input

Required attributes for HTML5 image input

I recently validated an HTML 5 page using the W3C validator service and was surprised to discover which attributes are required (and not required) for an image input. Note that of course the HTML5 specification is still under development at the time of this post so is subject to change.

What is required

If the input is empty then this validates just fine:

<input>

As soon as type="image" is added to the <input> some attributes become required.

I first tried validating some HTML that looked more or less like this:

<input id="myid" type="image" src="myfile.gif">

and got the error message:

Required attributes missing on element input.

Unfortunately the validator does not specify which attribute are required, instead just listing a whole bunch of attributes that are valid. I eventually managed to work out that it’s only the "alt" attribute that is required. Surprisingly for an input type="image" the "src" attribute is not required.

So this is the minimum valid requirement for an image input when using the W3C validtor to validate an HTML5 page:

<input type="image" alt="Alt Text Here">

Check Out These Related posts:

  1. PHP email validation using the Zend Framework
  2. NordVPN vs IPVanish
  3. Validating an IP address with PHP’s filter_var function
  4. RFC 1321 – MD5 Message-Digest Algorithm

Filed Under: HTML And CSS

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap