In HTML, you can use the style attribute on the button button element, add the "background-color: color value;" style to set the background color of the button, and add the "color: color value;" style to set the button font color.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
Set the background color of the button in html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <button>按钮1</button> <button style="background-color: #FFC0CB;">按钮2</button> </body> </html>
Rendering:
Description:
The background-color property sets the background color of the element.
The background-color property sets a solid color for the element. This color fills the element's content, padding, and border areas, extending to the outer bounds of the element's border (but not the margins). If the border has transparent parts (such as a dotted border), the background color will show through these transparent parts.
Set the font color of the button in html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <button>按钮1</button> <button style="color: blueviolet;">按钮2</button> </body> </html>
Rendering:
Description:
The color attribute specifies the color of the text.
This attribute sets the foreground color of an element (in HTML representation, the color of the element's text); raster images are not affected by color. This color also applies to all borders of the element, unless overridden by border-color or another border-color property.
Recommended tutorials: "html video tutorial", "css video tutorial"
The above is the detailed content of How to set button color in html. For more information, please follow other related articles on the PHP Chinese website!