{"id":322,"date":"2008-12-23T21:04:04","date_gmt":"2008-12-24T02:04:04","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=322"},"modified":"2008-12-23T21:04:04","modified_gmt":"2008-12-24T02:04:04","slug":"12-creative-and-cool-uses-for-the-css-border-property","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/12-creative-and-cool-uses-for-the-css-border-property\/","title":{"rendered":"12 Creative and Cool Uses for the CSS Border Property"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/random-art.gif\" alt=\"random art using the CSS border property\" title=\"random art using the CSS border property\" width=\"579\" height=\"175\" class=\"alignnone size-full wp-image-323\" \/><\/p>\n<p>If CSS properties attended high school, you would never expect to see the border property sitting at the cool kids&#8217; table. Sure, it&#8217;s a useful property and all &mdash; as long as you&#8217;re looking accentuate the boxiness of a design, right? <\/p>\n<p>Actually, you&#8217;d be surprised at just how cool the border property can be. Please take the following dozen exhibits as proof that the CSS border property is a lot cooler than we give it credit for.<!--more--><\/p>\n<h3>Jazzing Up Anchors<\/h3>\n<p><a href=\"http:\/\/cssnewbie.com\/style-your-links-with-css\/\">I&#8217;ve written here before about jazzing up anchor tags<\/a> by changing the color, removing the underline, and adding background images. But border can be a great way to add a bit of visual style to your anchors without adding that great bit of accessibility that the underline provides. For example, CSS Newbie&#8217;s article links are currently styled with a dotted border, like so:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">.entry a {\n\tcolor: #253c93;\n\ttext-decoration: none;\n\tborder-bottom: 1px dotted #253c93; }\n.entry a:hover {\n\tborder-bottom: 1px solid #253c93; }<\/pre>\n<p>That gives me a nice dotted border that turns solid when the user hovers over the link. All sorts of style and accessibility without that so-&#8217;90s underline.<\/p>\n<h3>Build a Postage Stamp<\/h3>\n<p><a href=\"http:\/\/cssnewbie.com\/example\/borders\/\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/stamp.jpg\" alt=\"CSS postage stamp\" title=\"CSS postage stamp\" width=\"536\" height=\"190\" class=\"alignnone size-full wp-image-324\" \/><\/a><\/p>\n<p>A while back, I ran across a cool little technique for faking a postage stamp using the CSS border property. The original link seems to have been lost from the web, but here&#8217;s the basic technique, in XHTML:<\/p>\n<pre lang=\"html4strict\" escaped=\"true\" line=\"1\">&lt;div class=&quot;stamp&quot;&gt;\n\t&lt;p&gt;99&amp;cent;&lt;\/p&gt;\n&lt;\/div&gt;<\/pre>\n<p>And CSS:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">.stamp {\n\twidth: 500px;\n\theight: 414px;\n\tbackground: #fff url(george.jpg) no-repeat;\n\tborder: 12px dashed #1b1a19; }\n.stamp p {\n\tcolor: #fff;\n\tmargin: 10px 10px 0 0;\n\tfont: bold 60px Georgia, \"Times New Roman\", Times, serif;\n\ttext-align: right; }<\/pre>\n<p>Now, you could obviously take this even further with a bit of skill and a degree in something other than Rhetoric, but I think you get the idea. <a href=\"http:\/\/cssnewbie.com\/example\/borders\/\">You can see the example live here.<\/a><\/p>\n<h3>Prettier Images<\/h3>\n<p>Borders are a great way to make your excellent images stand out even more. <a href=\"http:\/\/cssnewbie.com\/5-cssriffic-treatments-images\/\">I wrote an article on the subject a while back,<\/a> but here&#8217;s the basic idea:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">img.photo {\n\tborder: 1px solid #999;\n\tbackground-color: #fcfcfc;\n\tpadding: 4px;}<\/pre>\n<p>You can see a similar technique used on CSS Newbie&#8217;s current design around all of the images in the articles, as well as the ads in the sidebar. As you can see, the technique can be subtle but visually pleasing if used properly.<\/p>\n<h3>Homemade Coupons<\/h3>\n<p>If you&#8217;re ever required to design an online coupon, you needn&#8217;t turn straight to Photoshop or the like. You can craft a coupon easily with just a bit of CSS:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">.coupon {\n\twidth: 250px;\n\tpadding: 10px;\n\ttext-align: center;\n\tborder: 3px dashed #ccc; }<\/pre>\n<p>Just that speck of code gives me a nice coupon that looks something like this:<\/p>\n<p><a href=\"http:\/\/cssnewbie.com\/example\/borders\/\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/coupon.gif\" alt=\"CSS coupon\" title=\"CSS coupon\" width=\"285\" height=\"191\" class=\"alignnone size-full wp-image-326\" \/><\/a><\/p>\n<p>You&#8217;ll have your readers printing and clipping in no time.<\/p>\n<h3>Better Blockquotes<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/blockquote.gif\" alt=\"CSS blockquote\" title=\"CSS blockquote\" width=\"500\" height=\"75\" class=\"alignnone size-full wp-image-325\" \/><\/p>\n<p>Blockquotes are often useful, seldom used. But if you have a website that often refers to the words of others,<a href=\"http:\/\/cssnewbie.com\/six-ways-style-blockquotes\/\" title=\"Six Ways to Style Blockquotes\"> a well-styled blockquote will go a long way<\/a> towards impressing your readers with your borrowed prose:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">blockquote {\n\tmargin: 1em 3em;\n\tcolor: #999;\n\tborder-left: 2px solid #999;\n\tpadding-left: 1em; }<\/pre>\n<p>Just a touch of code, and voila&#8230; instant credibility!<\/p>\n<h3>Hunt Archaic Code<\/h3>\n<p><a href=\"http:\/\/cssnewbie.com\/deprecated-element-highlighting\/\" title=\"Find Deprecated Elements with Diagnostic CSS Highlighting\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/diagnostic.gif\" alt=\"diagnostic CSS\" title=\"diagnostic CSS\" width=\"400\" height=\"150\" class=\"alignnone size-full wp-image-327\" \/><\/a><\/p>\n<p>If you ever take over a website (or perhaps built a website) that is still using the Code of Yesteryear, consider turning to CSS and the border property for help hunting down bits of HTML soup that could use a bit less seasoning:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">font, center, s, u, b, i {\n\tcolor: #000;\n\tfont-weight: bold;\n\tbackground-color: #f99;\n\tborder: 3px solid #c00; }<\/pre>\n<p>For more information on this useful technique, <a href=\"http:\/\/cssnewbie.com\/deprecated-element-highlighting\/\" title=\"Find Deprecated Elements with Diagnostic CSS Highlighting\">see my article on finding deprecated elements with diagnostic CSS highlighting.<\/a> It just might save your life someday. But I doubt it.<\/p>\n<h3>Round the Bend<\/h3>\n<p><a href=\"http:\/\/cssnewbie.com\/easy-rounded-corners-with-border-radius\/\" title=\"Easy Rounded Corners with Border Radius\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/rounded-div.gif\" alt=\"CSS rounded  border\" title=\"CSS rounded  border\" width=\"400\" height=\"86\" class=\"alignnone size-full wp-image-328\" \/><\/a><\/p>\n<p>So far, all of our techniques have had one thing in common: boxy edges. But if you&#8217;re using a browser developed within the last five or so years (read: not IE6), you&#8217;re not limited to those same old dull right angles. <a href=\"http:\/\/cssnewbie.com\/easy-rounded-corners-with-border-radius\/\" title=\"Easy Rounded Corners with Border Radius\">This article from last August<\/a> shows us that CSS3 offers us a way of breaking out of &mdash; or at least bending the corners of &mdash; the CSS box:<\/p>\n<pre lang=\"css\" escaped=\"true\" line=\"1\">div.rounded {\n\tbackground-color: #666;\n\tcolor: #fff;\n\tfont-weight: bold;\n\tpadding: 10px;\n\t-moz-border-radius: 5px;\n\t-webkit-border-radius: 5px; }<\/pre>\n<p>The border-radius properties allow us to round the corners of elements without having to resort to images. Cool indeed!<\/p>\n<h3>Angle it In<\/h3>\n<p><a href=\"http:\/\/meyerweb.com\/eric\/css\/edge\/slantastic\/demo.html\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/slant.gif\" alt=\"Eric Meyer slant\" title=\"Eric Meyer slant\" width=\"400\" height=\"89\" class=\"alignnone size-full wp-image-329\" \/><\/a><\/p>\n<p>Of course, not all angles are bad angles&#8230; if used properly. Way back in the day, CSS guru Eric Meyer pointed out a way to use borders to create some pretty wicked angles. If you&#8217;d like to learn more about this technique, <a href=\"http:\/\/meyerweb.com\/eric\/css\/edge\/slantastic\/demo.html\">his site is a great place to start.<\/a><\/p>\n<h3>CSS Drawings<\/h3>\n<p>And now for a bit of fun!  The following excellent (and cool) examples are all drawn using the CSS border property.<\/p>\n<p><a href=\"http:\/\/www.tanfa.co.uk\/css\/borders\/clock-working.asp\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/lcd-clock.gif\" alt=\"CSS lcd clock\" title=\"CSS lcd clock\" width=\"389\" height=\"134\" class=\"alignnone size-full wp-image-330\" \/><\/a><\/p>\n<p>This functional LCD-style digital clock was built using CSS borders to create the lines of the LCD. <a href=\"http:\/\/www.tanfa.co.uk\/css\/borders\/clock-working.asp\">Check out tanfa.co.uk to see it in action!<\/a><\/p>\n<p><a href=\"http:\/\/www.intersmash.com\/border\/\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/skyline.gif\" alt=\"CSS skyline\" title=\"CSS skyline\" width=\"533\" height=\"166\" class=\"alignnone size-full wp-image-331\" \/><\/a><\/p>\n<p>There&#8217;s something very pop-art about <a href=\"http:\/\/www.intersmash.com\/border\/\">this CSS skyline.<\/a> It leans heavily on the border property to create the buildings and windows.<\/p>\n<p><a href=\"http:\/\/infimum.dk\/HTML\/randomArt.html\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/random-art.gif\" alt=\"random art using the CSS border property\" title=\"random art using the CSS border property\" width=\"579\" height=\"175\" class=\"alignnone size-full wp-image-323\" \/><\/a><\/p>\n<p><a href=\"http:\/\/infimum.dk\/HTML\/randomArt.html\">Here&#8217;s a random art generator<\/a> that combines HTML, JavaScript, and the CSS border property to create random examples of modern art. If you hit the &#8220;update&#8221; button long enough, you&#8217;re bound to find something worthy of hanging on your (cubicle?) wall.<\/p>\n<p><a href=\"http:\/\/www.designdetector.com\/tips\/3DBorderDemo2.html\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/12\/house.gif\" alt=\"CSS house\" title=\"CSS house\" width=\"500\" height=\"200\" class=\"alignnone size-full wp-image-332\" \/><\/a><\/p>\n<p>Christopher Hester is a man with fantastic CSS skill, incalculable patience, and presumably no girlfriend &mdash; at least until he started impressing the ladies with <a href=\"http:\/\/www.designdetector.com\/tips\/3DBorderDemo2.html\">this house he built with the CSS border property.<\/a> And be sure to check out <a href=\"http:\/\/www.designdetector.com\/demos\/css-house-2.html\">his second CSS house,<\/a> which he built using background colors and approximately 50 gazillion non-semantic divs.<\/p>\n<p>If you know of any other fantastic uses for the CSS border property, be sure to mention them in the comments!<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>If CSS properties attended high school, you would never expect to see the border property sitting at the cool kids&#8217; table. Actually, you&#8217;d be surprised at just how cool the border property can be. Please take the following dozen exhibits as proof that the CSS border property is a lot cooler than we give it credit for. [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/12-creative-and-cool-uses-for-the-css-border-property\/\" title=\"Click to read '12 Creative and Cool Uses for the CSS Border Property'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[168,192,193],"tags":[206,208,151,79,245,261,284],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/322"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}