Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
The outline-color Property in CSS
The outline-color property can be defined to draw a line of a specific color around the borders of the element, but the outline is not a part of element?s dimensions unlike border property.
Syntax
The syntax of CSS outline-color property is as follows −
Selector {
outline-color: /*value*/
}
The value can be a −
Color
RGB
RGBA
HSL
HSLA
NOTE − The outline-style property needs to be defined before declaring outline-color.
Example
Let?s see an example for the outline-color property. Here, we have set the outline color for the <span> −
outline-color: green;
Here is the example −
<!DOCTYPE html>
<html>
<head>
<title>CSS outline-color</title>
<style>
span {
margin: 15px;
padding: 20px;
border-style: solid;
border-color: #f28500 #dc3545;
position: absolute;
outline-width: 5px;
outline-style: double;
outline-color: green;
border-radius: 50%;
}
#showDiv {
margin:auto;
border-style: solid;
border-color: darkmagenta dodgerblue;
outline-style: groove;
outline-color: black;
height: 80px;
width: 80px;
}
#container {
width:50%;
margin:50px auto;
}
</style>
</head>
<body>
<div id="container">
<div id="showDiv"><span></span></div>
</div>
</body>
</html>
Example
Let?s see another example for outline-style property. In this example, we have set the outline color for the <p> −
border-color: lightblue;
Let us see the example −
<!DOCTYPE html>
<html>
<head>
<title>CSS outline-color</title>
<style>
#container {
width:50%;
margin:50px auto;
}
p {
margin:auto;
border-style: ridge;
border-width: 10px;
border-color: lightblue;
outline-style: dashed;
outline-width: 5px;
outline-color: violet;
}
</style>
</head>
<body>
<div id="container">
<p>Reach millions of professionals with video tutorials.</p>
</div>
</body>
</html>
Example
In this example, we have set the outline color using the RGB() value. The following is the syntax of the RGBA Color Values −
rgba(red, green, blue)
Above, the following values are added to the rgb() method.
Red
Set the color as an −
Integer between 0 and 255.
Percentage between 0% and 100%
Green
Set the color as an −
Integer between 0 and 255.
Percentage between 0% and 100%
Blue
Set the color as an −
Integer between 0 and 255.
Percentage between 0% and 100%
Here is the example −
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
outline-style: dashed;
outline-color: rgb(71, 30, 255);
border: 2px solid green;
}
h2 {
outline-style: dashed;
outline-color: rgb(168, 60, 10);
}
</style>
</head>
<body>
<h1>Demo Heading1</h1>
<h2>Demo Heading2</h2>
<p>Demo Text</p>
</body>
</html>
