Home  >  Article  >  Web Front-end  >  How to set button size and color in html

How to set button size and color in html

青灯夜游
青灯夜游Original
2021-03-05 17:16:4219460browse

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;}".

How to set button size and color in html

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(&#39;你好,世界!&#39;)">点我!</button>

	</body>

</html>

Rendering:

How to set button size and color in html

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.

Specifies the background color. transparentSpecifies that the background color should be transparent. This is the default
Value Description
##color
[Recommended tutorial:

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!

Statement:
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
Previous article:How to set scroll barNext article:How to set scroll bar