Create an HTML <input> Image Button Online
The HTML Image Input Generator creates an <input type="image"> control: a submit button displayed with an image. Set its image source, form name, alternative label, dimensions, and autofocus state; the preview, HTML output, and C# output update together.
Unlike an <img> element, an image input activates form submission. When a user clicks the displayed image, the browser can submit the selected x and y coordinates with the form data.
Image Input Generator Options
- URL sets the image resource in the
srcattribute. It can be a relative or absolute image URL. - Name provides the base name used for the submitted coordinate entries.
- Alt text supplies the required non-empty textual label when the image is unavailable or cannot be used.
- Height and Width set the rendered dimensions in CSS pixels and must be positive integers.
- Autofocus requests focus when the page loads.
Choose dimensions that preserve the source image’s aspect ratio. The generator normalizes invalid dimensions and uses Submit as a fallback when Alt text is empty.
Create an HTML Image Input in C#
The C# panel shows how to create the configured image submit button with Aspose.HTML for .NET . The generated code follows this workflow:
- Create an
HTMLDocumentand anHTMLInputElementwithCreateElement(). - Set its
Typetoimage, then assign the source, name, and non-empty alternative label. - Set the selected dimensions and optional
autofocusattribute. - Add the control with
AppendChild()and writeimage-input.htmlwithSave().
Configure the image button first, then copy the updated C# code into your .NET project.
HTML Image Input Generator FAQ
1. How does <input type="image"> differ from <img>?
An image input is a form submit button whose visual content comes from an image. An <img> embeds an image in document content and does not submit a form when activated.
2. What values does an image input submit?
It submits the selected image coordinates as two entries derived from the control name. For example, a control named checkout produces checkout.x and checkout.y values when the user selects a point on the image.
3. Why must the alt attribute contain text?
The text is the button’s label for users and user agents that cannot use the image. Describe the action, such as “Log in” or “Search,” rather than describing the image’s appearance.
4. Why does the image button not submit anything in the preview?
The generated control must have a form owner before activation can submit data. Place the copied input inside a <form> or associate it with a form when integrating it into the target page.
5. Should I enable autofocus for the image button?
Use it sparingly. Automatically moving focus can disorient keyboard and assistive-technology users, and a document should not contain competing autofocus targets.
Get Started with Aspose.HTML for .NET API
Install Aspose.HTML for .NET from NuGet with the .NET CLI:
dotnet add package Aspose.HTML
You can also use the NuGet Package Manager UI or run Install-Package Aspose.HTML in the Package Manager Console. See the
installation guide
for setup details, or request a
temporary license
to evaluate the API without evaluation limitations.
Other Supported HTML Generators
Create and preview markup for other common HTML elements.