search
HomeWeb Front-endHTML TutorialImage buttons using HTML5
Image buttons using HTML5Aug 20, 2023 pm 08:17 PM

Image buttons using HTML5

In the next article, we will learn about using HTML5 image buttons.

task we are making the image to act as a button, When the user clicks the button, the form is sent to the server. Let's look into it.

What is an image button

Image buttons are created by placing the Image buttons using HTML5 tag inside the

Image buttons using HTML5 Tag

By using the Image buttons using HTML5 tag we can include an image on a HTML page. Images are not actually embedded in the webpages; instead, they are connected to them via predetermined paths. The tag consists of two required attributes namely src and alt.

Syntax

Following is the syntax for Image buttons using HTML5 tag

<img src="/static/imghwm/default1.png"  data-src="https://www.tutorialspoint.com/coffeescript/images/coffeescript.jpg?x-oss-process=image/resize,p_40"  class="lazy"  src=”..” alt=”..”>

A clickable button is defined by the

Let’s look into the examples for understanding of image button with HTML5.

Example 1

In the example below, we are creating a simple image button.

<!DOCTYPE html>
<html>
<body>
   <p>Click On The Image</p>
   <button onclick="JavaScript:alert('DONT HUNT ANIMALS')">
   <img src="/static/imghwm/default1.png"  data-src="https://www.tutorialspoint.com/coffeescript/images/coffeescript.jpg?x-oss-process=image/resize,p_40"  class="lazy"     style="max-width:90%"  style="max-width:90%" alt="animal">
   <br>LOVE ANIMALS</button>
</body>
</html>

When the script gets executed, it will generate an output displaying the image button with text on it along with a prompt on the webpage.

When the user clicks the image button, the event gets triggered and displays an alert "Don’t hunt animals".

Example 2

In the example below, we create an image button using .

<!DOCTYPE html>
<html>
<body style="text-align: center">
   <h2 id="creating-an-image-Button-with-HTML">creating an image Button with HTML5?</h2>
   <form>
      USERNAME:
      <input type="name" /><br><br>
      PASSWORD:
      <input type="password" /><br><br>
      <input type="image" src=
      "https://www.tutorialspoint.com/images/logo.png"
      height="80px" width="110px"
      alt="submit" />
   </form>
</body>
</html>

When the script gets executed, it will generate an output displaying the input field for username and password along with an image button on the webpage. When the user clicks the image button, the form gets submitted to the server.

Example 3

In the example below, we use placeholders and an image button with

<!DOCTYPE html>
<html>
<head>
   <style>
      input[type='image'] {
         width: 80px;
      }
   </style>
</head>
<body style="text-align: center">
   <p>SIGN IN </p>
   <div>
      <input type="email"
      placeholder="Enter your email Address" />
      <br><br>
   </div>
   <input type="image" id="image" alt="Login"
   src="https://www.tutorialspoint.com/images/logo.png">
</body>
</html>

On running the above script, the output window will pop up, displaying the sign in provided with a placeholder for entering email along with an image button on the webpage.

Example 4

In the following we are creating a image button but inserting Image buttons using HTML5 tag inside the

<button type = "submit" name = "learn" value = "myimage">
   <p>Tutorials for all</p>
   <img  src="https://www.tutorialspoint.com/latest/inter-process-communication.png ?x-oss-process=image/resize,p_40" / alt="Image buttons using HTML5" >
</button>

After running the above script, it will generate an image button containing text on the web page.

The above is the detailed content of Image buttons using HTML5. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:tutorialspoint. If there is any infringement, please contact admin@php.cn delete
What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the viewport meta tag? Why is it important for responsive design?What is the viewport meta tag? Why is it important for responsive design?Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft