InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS border-color – define color of four borders

on Mar 14, 2016

The border-color property sets the color of the four borders.

CSS property border-color

CSS version: CSS 2.1
Value: [color|transparent]{1,4} | inherit
Initial: depends on user agent (individual properties)
Applies to: all elements
Inherited: no
Few points to note:

  1. When four values are specified this is the order:
    border-top-color, border-right-color, border-bottom-color, border-left-color
    
  2. When less than four values are specified:

    h1 { border-color: red }                   /* red red red red */
    h1 { border-color: red blue }             /* red blue red blue */
    h1 { border-color: red blue green }      /* red blue green blue */
    
  3. border-style must be set to something other than none and border-width should be > 0 for border-color to be applicable.

Example – border-color – top, right, bottom, left

<style type="text/css">
.box {
  width: 100px; height: 100px;
  border-style: solid;
  border-color: red blue green yellow;
}
</style>
<div class="box">
  Hello world in div
</div>
refresh done
try it online

Example – border-color transparent

Here background color is transparent and hence background color of the element itself is displayed.

<style type="text/css">
.box {
  width: 100px; height: 100px;
  background-color: lightgreen;
  border-style: solid;
  border-width: 15px;
  border-color: transparent;
}
</style>
<div class="box">
  Hello world in div
</div>
refresh done
try it online

Related

  • CSS border - define border properties of an element
  • CSS border-width - set element border width of four sides
  • CSS border-style tutorial and examples
  • CSS border radius and round corners examples

Specification

  • W3C CSS 2.1 border-color specification

Suggested posts:

  1. CSS border – define border properties of an element
  2. CSS color values
  3. CSS border radius and round corners examples
  4. CSS border-width – set element border width of four sides
  5. CSS background-color
  6. CSS border-style tutorial and examples
  7. CSS outline-color
  8. CSS color
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials, Web Development

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2023 InfoHeap.

Powered by WordPress