Advantages of Using Corners Without Images

In a previous tutorial, we looked at rounding corners with images using CSS. Though, the page can be optimized for loading speed further by using no images. CSS allows us to use styles that can achieve this effect. Rounded corners work well on sites that need to highlight content on the home page such as ads, new products or news.

Here is the result produced by the code given here:

This is so easy to edit for any usage. Here, the use of a DIV tag with the content means that it can be used with content that is positioned anywhere on the page. Expanding or shrinking the size of the DIV box is straightforward. It will automatically adjust itself to fit the content in the box. Rounded corners give pages with text boxes a more attractive appearance.

Now for the code:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />

<title>Corner without images</title>

<style type=”text/css”>

body{padding: 20px;background-color: #FFF;

font: arial}

h1,h2,p{margin: 0 10px}

h1{font-size: 250%;color: #FFF}

h2{font-size: 200%;color: #f0f0f0}

p{padding-bottom:1em}

h2{padding-top: 0.2em}

div#background{ margin: 0 10%;background: #9BD1FA} /* Setting the background for content and color */

b.rtop, b.rbottom{display:block;background: #FFF} /* Setting the corner color, use different color for different layout */

b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA}/* Setting the strip size and background

color */

b.r1{margin: 0 5px}

b.r2{margin: 0 3px}

b.r3{margin: 0 2px}

b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 1px}

</style>

</head>

<body>

<div id=”background”>

<b class=”rtop”><b class=”r1″></b><b class=“r2″></b><b class=”r3″></b><b class=”r4″></b></b>

<h1>Boxes Like This With Corners <br>Highlight Your Business Benefits</h1><br>

<p>There are many uses for these boxes. Rounded corners can add some spice to an otherwise dull page. </p>

<ul><li>Smooth Boxes</li><li>Easy To Set Up </li><li>Good for highlighting content</li></ul>

<h2>Have you tried rounded corners?</h2>

<p>Give it a whirl…and see if it can add some extra visual appeal to your web pages.</p>

<b class=”rbottom”><b class=”r4″></b><b class=”r3″></b><b class=”r2″></b><b class=”r1″></b></b>

</div>

</body>

</html>

Try placing the code into several types of pages such as tables and different designs. You will find it easy to use the code in various ways.

Go ahead, round those corners!

33 thoughts on “Advantages of Using Corners Without Images

  1. Lovely that this article is crap. The example does not work. I copied it, pasted into a file, ran it into apache and it prints out the text with no formatting, no nothing.

    The best part of the whole thing is that article is about using CSS to defined rounded corners without images AND THE EXAMPLE SHOWN ABOVE IS A .JPG file. I did a “view source” if I could figure out how to use CSS. Here is the .jpg file from the source
    http://images.ientrymail.com/rodney/rounded.jpg

  2. Mark:
    Worked for me. Rule of Thumb: Never just copy and paste the code from the website and expect it to work.

    You have to have knowledge of coding rules. When you copy the code on this page, it is not going to have the quotes correctly (anywhere, tags for instance. Very important to watch that, otherwise, the Character Entity for the quotes are going to be used and nothing will work. As you’ve experienced.you have to go through the code and replace them.
    Otherwise, it worked great.
    Thanks to the Author for sharing.

  3. …And; I’m sure the author used an image because they are posting to this website and are probably not administrators of it; I’m not sure if this site is configured in such a way to leave “Live” examples. In order to show you an example they post a picture of the example and paste their code in their post.

  4. I copied the code and set the quotation marks correctly, but this still does not work.

    All I see is a sharp cornered aqua box with some text in it.

    And really, why isn’t there an example page!?!?

    P.S.
    Tested on the three major browsers.

  5. Here’s something I’ve found that actually works…

    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;

    both for mozilla and webkit (won’t work on IE, not until 2018 anyway).

  6. I tried it and had the same problem as Mark, but once I read Robert’s comment and changed every single quote, it worked for me. Tested it on Chrome, Firefox and IE.

  7. It works. To make it work in IE6/7 as well as FF/Safari/mozilla and thereby all the browsers that actually matter, use the border-radius.htc file .

    so you’ll have this in the css:

    .whateverYouCallYourClass {
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    behavior:url(border-radius.htc);
    }

    and the html would be:
    content here</div

    Go to google.code.com and you can download the sample file that has the .htc file.

  8. It worked after I corrected the quotes. Thanks to the author for sharing. Retyped code follows below.

    Corner without images

    body{padding: 20px;background-color: #FFF; font: arial}
    h1,h2,p{margin: 0 10px}
    h1{font-size: 250%;color: #FFF}
    h2{font-size: 200%;color: #f0f0f0}
    p{padding-bottom:1em}
    h2{padding-top: 0.2em}

    div#background{ margin: 0 10%;background: #9BD1FA} /* Setting the background for content and color */

    b.rtop, b.rbottom{display:block;background: #FFF} /* Setting the corner color, use different color for different layout */
    b.rtop b, b.rbottom b{display:block;height: 1px; overflow: hidden; background: #9BD1FA} /* Setting the strip size and background color */

    b.r1{margin: 0 5px}
    b.r2{margin: 0 3px}
    b.r3{margin: 0 2px}
    b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 1px}


    Boxes Like This With Corners Highlight Your Business Benefits
    There are many uses for these boxes. Rounded corners can add some spice to an otherwise dull page.
    Smooth BoxesEasy To Set Up Good for highlighting content
    Have you tried rounded corners?
    Give it a whirl…and see if it can add some extra visual appeal to your web pages.

  9. This example works! I tried it on Eclipse (not on other browsers yet). Thing is, if you paste the example, you need to replace all the quotes in the code, even the ones that look good.

    Really like this example, thanks!!

  10. This is not really good by default, till I changed the last line of the style:

    b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px}

    The height is changed into 2px, and everything works well. (without zoom)

  11. I’m new to CSS (older school PHP / MySQL / Web 2.0 developer taking another swing at making webpages). My opinion is that if you’re giving an example, you should make the example as concise as possible. I bet you could remove 80% of the text from this page and still teach how to make rounded corners. I didn’t learn how to make CSS rounded corners from this page. This page is a great example: http://www.css3.info/preview/rounded-border/

  12. Very good work. Rounded Corners in plain css and no images!.
    Yes small stuff to correct around like quotes on a cut and paste. Other than that it definitely works.
    Cheers!

    Peter

  13. I got this example to work after adjusting it, but I noticed that the corners themselves aren’t very adjustable, if you increase the size of them it makes the effect look bad.

  14. I read all the comments, corrected the quotes, prettied up the code to make it more presentable and it did not work at all, before or after I altered it. Square corners in FF, IE, Chrome and Opera. Very bad example.

  15. Thanks for giving us the live link.

    Been studying this for a while and I hope could master this.

    Round corners is pretty coll effect and will use this to edit my site.

    Thanks for the author.

  16. Please don’t use smart quotes: it makes copy/pasting your sample code a bit of a pain.

    Actually, I would recommend embedding the code itself in the page and letting people use their browser’s “inspect element” to explore the sample.

  17. Works perfectly in IE, Opera, Chrome and firefox. To have larger rounded corners, you need to add more r classes.

    Not perfect, but until browsers fully support CSS3, it’s probably the best fix out there with cross browser support.

  18. Pingback: 25 Rounded Corners Techniques with CSS « Impact Web Design Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>