Home Web Front-end HTML Tutorial The forgotten button tag_HTML/Xhtml_Web page production

The forgotten button tag_HTML/Xhtml_Web page production

May 16, 2016 pm 04:45 PM
action Can us button Label

Note: This article has been translated by someone to re-understand the button tag, but I feel that there are many places worthy of scrutiny and it is not easy to understand. Therefore, I re-translated this article based on my personal learning experience.
English original text: http://particletree.com/features/rediscovering-the-button-element/
For every program designer, provide users with a unified style interface is an unchanging requirement. However, it is extremely difficult to achieve this unified style on web pages, because there are differences in the way different operating systems and different browsers express web content, and these differences are almost irregular. This problem is particularly prominent in the process of processing form elements. Among them, what leaves many people at a loss is the problem of unifying the performance standards of the "Submit" button.
For example, the input tag with the attribute type="submit" either looks very ugly in different browsers (in Firefox), or has defects of one kind or another (in Internet Explorer), or even behaves very rigidly. (in Safari). The solution to this problem is usually to set the input attribute to image and then design a button image yourself. But this adds a lot of extra annoying work every time we need to use the button. Therefore, we need a better solution, one that is more flexible and meaningful to designers. Fortunately, this method already exists in practice, it just requires a little more work on our part. Friends, please allow me to introduce to you our lovely little friend
They behave as follows:

There is no difference in operation and behavior between these buttons and the buttons we created above. In addition to using them to submit forms, you can also set them to be disabled, add shortcut keys or set a tabindex, etc. Fortunately, except for the different presentation styles, Safari supports these functions (compared with the input button, the button button in Safari lacks the liquid effect on the surface). The coolest feature of the
They look like this in the browser:

Not bad. In fact, according to the W3C definition, the


Change Password



Cancel


The purpose of this is because many actions in web applications are event (REST) ​​driven, so sending user requests through a specific URL can initialize these actions. Using styles that can be applied to both elements gives us greater flexibility in maintaining style uniformity for interactions caused by Ajax and standard submit buttons.
Now you may ask, why should I leave the alt attribute of the image element blank? alt is a necessary attribute of the img element. It is used to explain the content of the image, but there is no description of the image here, which is indeed a bit puzzling. However, unlike the "missing" attribute, the attribute value "null" is fully compliant with the standard. It tells the browser that these images represent some information that can be completely ignored, which also prevents the viewer from being unable to find it because of the obstruction of the prompt information. Go to next button. Since the icon here is completely redundant, we would rather not waste the user’s time looking at this icon that is used entirely to achieve a unified interface style.
CSS style sheet
Most of the CSS used to control the styles of these buttons is very intuitive. Slight differences in different browsers will cause us to separate them in the code below. Applying different padding values, fortunately, all this is completely achievable.
/* BUTTONS */
.buttons a, .buttons button{
display:block;
float:left;
margin:0 7px 0 0;
background-color:#f5f5f5;
border:1px solid #dedede;
border-top:1px solid #eee;
border-left:1px solid #eee;
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:100%;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:# 565656;
cursor:pointer;
padding:5px 10px 6px 7px; /* Links */
}
.buttons button{
width:auto;
overflow:visible;
padding:4px 10px 3px 7px; /* IE6 */
}
.buttons button[type]{
padding:5px 10px 5px 7px; /* Firefox */
line-height: 17px; /* Safari */
}
*:first-child html button[type]{
padding:4px 10px 3px 7px; /* IE7 */
}
.buttons button img, .buttons a img{
margin:0 3px -3px 0 !important;
padding:0;
border:none;
width:16px;
height:16px;
}
Another problem is that Internet Explorer has some bugs when rendering long buttons. You can find information about this on Jehiah.cz, but in the above CSS code we can avoid the problem to a certain extent by declaring the values ​​of width and overflow.
Add a little color to the button
In Wufoo, we use neutral actions (here, the author calls actions such as change password neutral actions, and "OK" and "Submit" "Actions of the type "are called positive actions, and actions such as "Give up" and "Cancel" are called negative actions). The hover value is set to blue, and the positive and negative actions are set to green and red. In the style code below, we use different colors to distinguish positive actions such as "add" and "save" and negative actions such as "cancel" and "delete". It feels pretty good, and of course you can also choose the color you like.
/* STANDARD */
button:hover, .buttons a:hover{
background-color:#dff4ff;
border:1px solid #c2e1ef;
color:#336699;
}
.buttons a:active{
background-color:#6299c5;
border:1px solid #6299c5;
color:#fff;
}
/* POSITIVE */
button.positive, .buttons a.positive{
color:#529214;
}
.buttons a.positive:hover, button.positive:hover{
background-color:#E6EFC2 ;
border:1px solid #C6D880;
color:#529214;
}
.buttons a.positive:active{
background-color:#529214;
border:1px solid #529214;
color:#fff;
}
/* NEGATIVE */
.buttons a.negative, button.negative{
color:#d12f19;
}
.buttons a.negative:hover, button.negative:hover{
background:#fbe3e4;
border:1px solid #fbc2c4;
color:#d12f19;
}
. buttons a.negative:active{
background-color:#d12f19;
border:1px solid #d12f19;
color:#fff;
}
Summary
The last thing I want to say is that this is just a solution we designed to meet the needs in Wufoo, but it performed well with our efforts. But that’s not the only way, you can find more interesting ways to make your buttons rounded or even more colorful. Since almost any other element can be placed between the
Definition and Usage
Define a button. Inside the button element, you can place content, such as text or images. This is the difference between this element and buttons created using input elements.
tags is the content of the button, including any acceptable body content, such as text or multimedia content. For example, we can include an image and associated text in a button and use them to create an attractive markup image in the button.
The only prohibited element is image mapping, as its mouse and keyboard-sensitive actions interfere with the behavior of form buttons.
Selectable attributes
Attribute value description DTD
disabled disabled Disable this button. STF
namebutton_name specifies a unique name for this button. STF
type* button
* reset defines the type of button. STF
* submit
value some_value specifies the initial value of the button. This value can be modified by scripts. STF
Standard attributes:
id, class, title, style, dir, lang, xml:lang, accesskey, tabindex
Event attributes:
onfocus, onblur, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

5 Ways to Disable Delivery Optimization Service in Windows 5 Ways to Disable Delivery Optimization Service in Windows May 17, 2023 am 09:31 AM

There are many reasons why you might want to disable the Delivery Optimization service on your Windows computer. However, our readers complained about not knowing the correct steps to follow. This guide discusses how to disable the Delivery Optimization service in a few steps. To learn more about services, you may want to check out our How to open services.msc guide for more information. What does Delivery Optimization Service do? Delivery Optimization Service is an HTTP downloader with cloud hosting solution. It allows Windows devices to download Windows updates, upgrades, applications and other large package files from alternative sources. Additionally, it helps reduce bandwidth consumption by allowing multiple devices in a deployment to download these packages. In addition, Windo

How to restart, force restart, and shut down iPad Mini 6 How to restart, force restart, and shut down iPad Mini 6 Apr 29, 2023 pm 12:19 PM

How to Force Restart iPad Mini 6 Force restarting iPad Mini 6 is done with a series of button presses, and it works like this: Press and release for Volume Up Press and release for Volume Down Press and release the Power/Lock button until you see Apple logo, indicating that the iPad Mini has been force restarted. That’s it. You have force restarted the iPad Mini 6! Force restart is usually used for troubleshooting reasons, such as the iPad Mini freezing, apps freezing, or some other general misbehavior. One thing to note about the procedure for force restarting the 6th generation iPad Mini is that for all other devices that have ultra-thin bezels and use

After rewriting:

How to Fix PS5 Controller Not Recognized on Windows 11 After rewriting: How to Fix PS5 Controller Not Recognized on Windows 11 May 09, 2023 pm 10:16 PM

<h3>What should I know about connecting my PS5 controller? </h3><p>As good as the DualSense controller is, there have been reports of the controller not connecting or not being detected. The easiest way to solve this problem is to connect the controller to your PC using an appropriate USB cable. </p><p>Some games natively support DualSense. In these cases, you can simply plug in the controller. But this raises other questions, like what if you don't have a USB cable or don't want to use one

Change the power button action on Windows 11 [5 Tips] Change the power button action on Windows 11 [5 Tips] Sep 29, 2023 pm 11:29 PM

The power button can do more than shut down your PC, although this is the default action for desktop users. If you want to change the power button action in Windows 11, it's easier than you think! Keep in mind that the physical power button is different from the button in the Start menu, and the changes below won't affect the operation of the latter. Additionally, you'll find slightly different power options depending on whether it's a desktop or laptop. Why should you change the power button action in Windows 11? If you put your computer to sleep more often than you shut it down, changing the way your hardware power button (that is, the physical power button on your PC) behaves will do the trick. The same idea applies to sleep mode or simply turning off the display. Change Windows 11

How to use Vue to implement button countdown effects How to use Vue to implement button countdown effects Sep 21, 2023 pm 02:03 PM

How to use Vue to implement button countdown effects With the increasing popularity of web applications, we often need to use some dynamic effects to improve user experience when users interact with the page. Among them, the countdown effect of the button is a very common and practical effect. This article will introduce how to use the Vue framework to implement button countdown effects and give specific code examples. First, we need to create a Vue component that contains a button and countdown function. In Vue, a component is a reusable Vue instance, and a view will

iOS 17: How to organize iMessage apps in Messages iOS 17: How to organize iMessage apps in Messages Sep 18, 2023 pm 05:25 PM

In iOS 17, Apple not only added several new messaging features, but also tweaked the design of the Messages app to give it a cleaner look. All iMessage apps and tools, such as the camera and photo options, can now be accessed by tapping the "+" button above the keyboard and to the left of the text input field. Clicking the "+" button brings up a menu column with a default order of options. Starting from the top, there's camera, photos, stickers, cash (if available), audio, and location. At the very bottom is a "More" button, which when tapped will reveal any other installed messaging apps (you can also swipe up to reveal this hidden list). How to reorganize your iMessage app You can do this below

How to reset your Xbox Series S or X controller How to reset your Xbox Series S or X controller Jun 03, 2023 pm 08:19 PM

The Xbox gaming console is a favorite among gamers. With the new SeriesX and SeriesS, gaming is almost a lifelike experience. The Xbox controller is your primary tool for experiencing gaming effects. Sometimes the controller connection gets cut off or some errors are encountered while trying to connect the controller to the main console. This may be due to various issues related to pairing. This can be overcome with a few simple steps. Reset your Xbox Series S or Xbox Series X controller Step 1: Press and hold the Xbox button on your controller for a few seconds to turn off the controller. Step 2: On the screen, go to Turn off controller and press button A to select that option. NOTE: If you keep pressing X

The new production information of the new open world game 'Wang Yue' has been released: a new world emerges in 48 Days The new production information of the new open world game 'Wang Yue' has been released: a new world emerges in 48 Days Feb 07, 2024 pm 03:36 PM

The two-dimensional open world action game "Wang Yue" owned by Shiyue Network recently released a new production information "48 Days Lives a New World", which introduced a series of optimization content of 48 Days since the last time it released production information, mainly the game screen. Iteration on performance. Among them, the display of the character UI interface has aroused heated discussions among many players, saying that it looks very familiar. Perhaps this kind of character display with multiple lenses running smoothly is becoming a new trend. Producer Hua Tao previously stated that the game has been in production for more than two years and will start its first test in the first quarter of 2024. Yesterday, the official also released a reservation video ""It seems like a pleasant afternoon"". It must be that the first test is not far away.

See all articles