Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Property Border-Color Not Working

Tags:

css

border

I have issue with border-color. It didn't work. I'm new to css here is the fiddle. http://jsfiddle.net/zeburrehman/aFzKy/151/

<div id="box"> Hello! The color of box border should be red!! </div>​  #box { border-color: red; }​ 
like image 977
Zeb-ur-Rehman Avatar asked Jan 04 '13 11:01

Zeb-ur-Rehman


People also ask

Why is border not working in CSS?

CSS Border Not Showing If you've set the shorthand border property in CSS and the border is not showing, the most likely issue is that you did not define the border style. While the border-width and border-color property values can be omitted, the border-style property must be defined. Otherwise, it will not render.


2 Answers

By default the border-width is 0 and border-style is none

So you need to set them to border-width:1px and border-style:solid. You can combine all the border properties into one as below:

#box {     border:1px solid red } 
like image 89
Ashwin Avatar answered Oct 02 '22 22:10

Ashwin


I had an issue where it seemed that border-color was not being respected, confusingly it even showed having the right color in the style inspector in Chrome (possibly a Chrome bug). The key thing for me was that if the shorthand border style is specified, it sets all three aspects of the border style, regardless of if they are included or not so:

border-left: 1px; 

Actually overwrites both the border-left-style and border-left-color properties even though they weren't included. This can for example cause an inherited style to be overridden and appear not to work.

like image 20
Shaun Avatar answered Oct 02 '22 22:10

Shaun