InfoHeap
Tech
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 – define border properties of an element

on Feb 16, 2016

CSS border property can be used to define border properties of an element.

CSS property border

CSS version: CSS 2.1
Value: [border-width || border-style || color] | inherit
Initial: see individual properties
Applies to: all elements
Inherited: no
Few points to note:

  1. To inherit border from parent, value inherit can be used. By default border is not inherited.
  2. We can separately define border-width, border-style and border-color. These properties can take 4 values (for top, right, bottom and left border).
  3. We can also use border-top, border-right, etc. to have different style for each border side.
  4. We can also use border-top-width, border-top-style, etc.
  5. Some commonly used style values are solid, dotted, dashed, etc.

Border basic example

<style type="text/css">
.foo {
 width: 100px; height: 100px;
 border: 4px solid lightgreen;
}
</style>
<div class="foo">
Hello world in div
</div>
refresh done
try it online

Border for each border side separately

<style type="text/css">
.foo {
  width: 100px; height: 100px;
  border-top-width: 10px;
  border-top-style: solid;
  border-top-color: red;
  border-right:4px dashed gray;
  border-left:5px dotted green;
  border-bottom:5px dotted red;
}
</style>
<div class="foo">
Hello world in div
</div>
refresh done
try it online

Related

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

Specification

  • W3C CSS 2.1 border specification

Suggested posts:

  1. CSS border-width – set element border width of four sides
  2. CSS list-style – shorthand for list marker type, image and position
  3. HTML ol tag
  4. Css :first-child selector – first child element
  5. CSS class selectors – define style by class name
  6. CSS pseudo class :visited – style for visited links
  7. jQuery – get checkbox value and checked state
  8. CSS animation shorthand property
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials, Web Development
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | 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 | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress