Home > Article > Web Front-end > How to set button size and color in html
In HTML, you can use the width and height attributes to set the size of the button element, and use the background-color attribute to set the color of the button element. The specific syntax is "button{width: width value; height: height value ;background-color: color value;}".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
HTML
Inside the
htmlSet button size and color
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> button{ width:100px; height: 100px; background-color: palevioletred; } </style> </head> <body> <button type="button" onclick="alert('你好,世界!')">点我!</button> </body> </html>
Rendering:
css width and height Properties
width property sets the width of the element.
The height attribute sets the height of the element.
Value | Description |
---|---|
auto | Default value. The browser can calculate the actual width or height. |
length | Define width or height using units such as px, cm, etc. |
% | # Defines a percentage width or height based on the width of the containing block (parent element). |
CSS background-color property
The background-color property sets the background color of an element.
Value | Description |
---|---|
##color | Specifies the background color.|
Specifies that the background color should be transparent. This is the default |
CSS video tutorial]
The above is the detailed content of How to set button size and color in html. For more information, please follow other related articles on the PHP Chinese website!