Home > Article > Web Front-end > How to set image button in html
htmlHow to set a picture button: first create an HTML sample file; then create a button through the button tag; and finally set the picture through the background attribute.
The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.
Turn pictures into buttons in html
The code is as follows:
<input type="image"> <input type="submit" style="background: url('图') no-repeat;"> <input type="button" style="background: url('图') no-repeat;" οnclick="提交的js"> <button style="background: url('图') no-repeat;" οnclick="提交的js">文字</button> <img src="图" οnclick="提交的js" alt="How to set image button in html" > <span style="border:1px solid #000000;background: url('图') no-repeat;" οnclick="提交的js"> </span>
Related introduction:
tag To collect user information.
According to different type attribute values, the input field has many forms. Input fields can be text fields, checkboxes, masked text controls, radio buttons, buttons, etc.
Background shorthand property sets all background properties in one declaration.
You can set the following properties:
background-color
background-position
background-size
background-repeat
background-origin
background-clip
background-attachment
background-image
If one of the values is not set, it will not There will be problems, such as background:#ff0000 url('smiley.gif'); is also allowed.
It is generally recommended to use this attribute instead of using individual attributes separately, because this attribute is better supported in older browsers and requires fewer letters to be typed.
【Recommended learning: html video tutorial】
The above is the detailed content of How to set image button in html. For more information, please follow other related articles on the PHP Chinese website!