Home >Web Front-end >Front-end Q&A >How to set the border color in css

How to set the border color in css

青灯夜游
青灯夜游Original
2021-09-14 17:07:065291browse

How to set the border color in css: 1. Use the border attribute, the syntax "border:yansezhi;"; 2. Use the border-color attribute, the syntax "border-color:yansezhi;". Color values ​​can be defined using color names, hexadecimal values, RGB or RGBA, HSL, etc.

How to set the border color in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Method 1: Use border attribute

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style type="text/css">
			div{ 
				margin: 10px;
				border:solid #FFC0CB;
			}
		</style>
	</head>
	<body>
		<div>测试文字</div>
		<div>测试文字</div>
		<div>测试文字</div>
	</body>
</html>

Rendering:

How to set the border color in css

Method 2: border-color attribute

border-color attribute is used to set the color of the four borders.

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style type="text/css">
			div{ 
				margin: 10px;
				border:solid;
				border-color: bisque;
			}
		</style>
	</head>
	<body>
		<div>测试文字</div>
		<div>测试文字</div>
		<div>测试文字</div>
	</body>
</html>

Rendering:

How to set the border color in css

The color value can be set in the following ways:

  • name - specify the color name , such as "red"

  • HEX - Specify a hexadecimal value, such as "#ff0000"

  • RGB - Specify an RGB value, such as "rgb(255,0,0)"

  • HSL - Specify the HSL value, such as "hsl(0, 100%, 50%)"

  • transparent

Related recommendations: "css video tutorial"

The above is the detailed content of How to set the border color in css. 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