break free by learning
  • Home
  • About
  • Free Stuff

CSS Tip – Different Color Borders

Apr 25, 2008 | css | fyd

A quick CSS tip. Don't want your css border to have the same color for every side. Well, you can make each side have a different color – it's easy.

.exampleBox
{
width: 100px;
height: 100px;
border: 3px solid #000000;
border-color: #ff00ff #00ff00 #0000ff #00ffff;
}

Some text in the box

Let's take a closer look at the css border properties. We start off by creating a border: that has a 3px 'stroke' that is solid and the color black. The next property we use is border-color:. The format here is TOP, RIGHT, BOTTOM, LEFT – or clockwise around the square starting from the top. Even though we set a color in the border: property, we put border-color below it which gives it precedence – or it 'overwrites' the border's color.

Need the HTML – I used an embedded stylesheet here, but this will work the same in an external stylesheet.

<html>
<head>
<title>CSS Different Colored Border</title>

<style type="text/css">
.exampleBox
{
width: 100px;
height: 100px;
border: 3px solid #000;
border-color: #ff00ff #00ff00 #0000ff #00ffff;
}
</style>
</head>

<body>

<div class="box">
<p>
Some text in the the box
</p>
</div>

</body>
</html>

Popularity: 11% [?]

Related Post:

  • CSS Tip – Using Link Anchor Pseudo Classes (7)
  • CSS Custom Search Field or Textfield (38)
  • CSS Gradient Background Fade (19)

Leave a Reply

Click here to cancel reply.

Categories

  • css (8)
  • freelance (2)
  • illustrator (1)
  • inspiration (4)
  • jquery (1)
  • photoshop (9)
  • resources (8)
  • site news (6)
  • the basics (4)
  • web design (1)
  • whats good (1)
  • wordpress (1)

Recent Posts

    Archives

    • April 2010 (1)
    • April 2009 (1)
    • May 2008 (3)
    • April 2008 (14)
    • March 2008 (8)
    • February 2008 (8)
    • January 2008 (11)

    ©2012 freeyourdesign | Designed by Michael Hargis | | twitter icons