How to set the border color in css

青灯夜游
Release: 2023-02-17 14:49:01
Original
5218 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template