Web888.vn
  • Shop
  • Blog
Đăng nhập
  • Đăng nhập / Đăng ký

Please enter key search to display results.

Home
  • HTML programming
  • Technology News
Button tag in HTML

Button tag in HTML

  • 24-07-2022
  • Trung Minh
  • 0 Comments

In this article, I will show you how to use the button tag in HTML, this is a very important tag in the html form structure.

The button tag creates a button, it doesn't create a form submit action like the input tag does. Therefore, we often use it in combination with Javascript to create the required actions of the problem.

In the <button></button> tag pair, the user can set the content to be a piece of text or an image. This is the difference between button tag and input tag with type = button .

1. How to use the button tag in HTML

For example , create a button to show greetings when clicked.

 <!DOCTYPE html> <html> <head> <title>Học lập trình miễn phí tại web888.vn</title> <meta charset="utf-8"> </head> <body> <h1>Học lập trình miễn phí tại web888.vn</h1> <button type="button" onclick="alert('Hello web888.vn!')" > Click để in ra lời chào web888 </button> </body> </html>

In the above example, I created an onclick event for the button tag so that when the button is clicked, it will alert the text ' Hello world! '.

2. Attribute of button tag in html

Here are some of the most commonly used attributes.

  • autofocus – automatically focus on the tag when the page loads.
  • type – will specify the style of the button, including: submit, reset, button.
  • name – the name of the button.
  • disabled – whether the button is disabled or not.

For example , use the type attribute to create a button that resets the entered data.

 <form> <input type="text" name="username"> <input type="text" name="email"> <button type="reset">Reset</button> </form>

3. Set CSS for button . tag

To add CSS to the button, you can use two ways:

  • The first way is to add a style attribute and write the CSS right inside.
  • The second way is to give the input tag a class or id, and then use this information to generate CSS.
 <button class="color-red" id="btn" type="reset">Reset</button> <style> button{ color:red } .color-red{ color:red } #btn{ color:red } </style>

Of the three methods above, you can use any of them.

Bài viết liên quan:

Installing PHP and introducing PHP basics
Instructions for using the plugin wp bakery builder (visual composer) to make a landing page
Instructions for installing and activating Office 2013
15 pocket tips in daily life you should know
What is WordPress and why should learn about wordpress?
Install composer use for Xampp on Windows
Guide to debug (debug) when programming C/C++ with Dev C++
Binary integer representation and binary operations
Create Gmail STMP and install for WordPress, Laravel, php…
Install and enable fileinfo extension in PHP 7 linux (centos,ubuntu)
The thing that limits your growth is the relationship you have
10 groups of customers that business people often encounter and how to behave professionally

THÊM BÌNH LUẬN Cancel reply

Dịch vụ thiết kế Wesbite

NỘI DUNG MỚI CẬP NHẬT

Step-by-step guide to installing Microsoft SQL Server and connecting to the database for beginners

Reasons Why People Are Increasingly Inexperienced in Life

PHP Data Types

Table (table) in SQL Server

Basic data types in C

Giới thiệu

web888.vn là chuyên trang chia sẻ và cập nhật tin tức công nghệ, chia sẻ kiến thức, kỹ năng. Chúng tôi rất cảm ơn và mong muốn nhận được nhiều phản hồi để có thể phục vụ quý bạn đọc tốt hơn !

Liên hệ quảng cáo: [email protected]

Kết nối với web888

© web888.vn - Tech888 Co .Ltd since 2019

Đăng nhập

Trở thành một phần của cộng đồng của chúng tôi!
Registration complete. Please check your email.
Đăng nhập bằng google
Đăng kýBạn quên mật khẩu?

Create an account

Welcome! Register for an account
The user name or email address is not correct.

Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy.

Registration confirmation will be emailed to you.
Log in Lost your password?

Reset password

Recover your password
Password reset email has been sent.
The email could not be sent. Possible reason: your host may have disabled the mail function.
A password will be e-mailed to you.
Log in Register
×