Home arrow Style Sheets arrow Page 2 - CSS: Crossing the Border
STYLE SHEETS

CSS: Crossing the Border


In our previous tutorials we discussed working with text and fonts in your cascading style sheets. Here, we will discuss working with the various border properties. There are a lot of ways to manipulate them, so let's dive right in.

Author Info:
By: James Payne
Rating: 4 stars4 stars4 stars4 stars4 stars / 5
March 24, 2008
TABLE OF CONTENTS:
  1. · CSS: Crossing the Border
  2. · Setting Different Borders Around An Element
  3. · How to Set the Border Width
  4. · How to Set Border Colors

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
CSS: Crossing the Border - Setting Different Borders Around An Element
(Page 2 of 4 )

If you wish to set different borders around an object, that is possible also. Note that the order goes like this: top, right, bottom, left.


<html>

<head>

<style type="text/css">

p.sample

{

border-style: dashed inset dotted hidden;

text-align: left;

}

p.secondsample {border-style: solid dashed solid dashed; text-align: center}

p.thirdsample {border-style: dashed groove solid groove; text-align: right}

p.three {border-style: solid double groove}

</style>

</head>

<body>

<p class="sample">Kiss my grits!</p>

<p class="secondsample">Stifle!</p>

<p class="thirdsample">Dingbat!</p>

</body>

</html>

For example, the first border is set so that the top border is dashed, the right border is inset, the bottom border is dotted, and left border is hidden.

Setting One Part of a Border

The following samples will each display only one part of a border:

The Top


<html>

<head>

<style type="text/css">

p

{

border-top: medium solid #ff0000

}

</style>

</head>

<body>

<p>I will not eat brown grits and spam.</p>

<p>I will not eat them on a train. </p>

<p> I will not eat them on a plane</p>

<p> I will not eat them with guacamole</p>

<p>But I will eat them for Angelina Jolie</p>

<p>What? You think <i>you</i> can rhyme better?!?</p>

</body>

</html>

The Bottom


<html>

<head>

<style type="text/css">

p

{

border-bottom: medium dashed #ff0000

}

</style>

</head>

<body>

<p>I will not eat brown grits and spam.</p>

<p>I will not eat them on a train. </p>

<p> I will not eat them on a plane</p>

<p> I will not eat them with guacamole</p>

<p>But I will eat them for Angelina Jolie</p>

<p>What? You think <i>you</i> can rhyme better?!?</p>

</body>

</html>

The Left


<html>

<head>

<style type="text/css">

p

{

border-left: medium solid green

}

</style>

</head>

<body>

<p>I will not eat brown grits and spam.</p>

<p>I will not eat them on a train. </p>

<p> I will not eat them on a plane</p>

<p> I will not eat them with guacamole</p>

<p>But I will eat them for Angelina Jolie</p>

<p>What? You think <i>you</i> can rhyme better?!?</p>

</body>

</html>

The Right


<html>

<head>

<style type="text/css">

p

{

border-right: medium solid blue

}

</style>

</head>

<body>

<p>I will not eat brown grits and spam.</p>

<p>I will not eat them on a train. </p>

<p> I will not eat them on a plane</p>

<p> I will not eat them with guacamole</p>

<p>But I will eat them for Angelina Jolie</p>

<p>What? You think <i>you</i> can rhyme better?!?</p>

</body>

</html>


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...
- CSS3 Animated Image Gallery: Transitions
- CSS3 Properties: Fixed Heights with box-sizi...
- CSS3 Properties: Altering Strokes and 3D Eff...
- CSS3 Properties: Text-Stroke
- CSS3 Transitions: Width and Height Properties
- Creating a Drop Down Menu in CSS3
- Intro to CSS Transitions

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials