When we talk about table-less HTML/xHTML coding, the first thing that comes to your mind is DIV. To create rounded corners, coders have been depending on DIVs all the time. Yes of course, it’s been the best in the de facto standard in html coding business.
However I’d like to give you an idea about another way of building a rounded corner box without using DIVs.
Assume that you’ve been asked to slice the following box and code it with HTML.
You’d start slicing the box according to the way below. It contains three parts. The top, middle and the bottom slices. It is really important to optimize all these slices to get the best performance on the web. For this reason, the above mentioned slices should be cut off to their smallest outward appearance without losing the quality of the image.
Now Let’s see how to code this box using the unordered list (<ul>) tag.
<ul>
<li></li>
<li></li>
<li></li>
</ul>
Here I’ve used three list items for the top, middle and the bottom slices. Now have a look at the way to apply CSS styles to make the rounded box.
ul.box{list-style-type:none;padding:0;margin:0;width:200px;}
The above style class will remove the list item, bullets and the default padding and margins.
ul.box li{float:left;width:200px;}
We can group the common styles for the list items(<li>) as above.
ul.box li.top{height:5px;background-image:url(images/top.jpg);overflow:hidden;}
Now we’ve just applied the box top graphics using CSS.
ul.box li.mid{height:140px;background-image:url(images/mid.jpg);background-repeat:repeat-y;}
Above I’ve shown how to code the middle part of the box using CSS.
ul.box li.bot{height:5px;background-image:url(images/bot.jpg);overflow:hidden;}
Finally, the box bottom has been completed. Your rounded corner box with HTML is now ready.
8 Comments
Join the discussion and tell us your opinion.
as you may know very well than me these days blogs are cropping up all over the place.most people starting such blogs think,they can write anyway and anything on there blog which is definately not true.but your blog solely stands out for your writing style,it is actually quite engrossing.keep at it.
Enjoyed reading/following your page.Please keep it coming. Cheers!
Excellent & thoughtful post.
I am not a person who is easily delighted but I have to say your work blew me away. So much ideas and relevant detaisl that you put into it made me see your point of view. Thanks for communicating your reasonable inputs.
Very good article I enjoy your website keep up the great blog posts
This is the coolest website and stories that i have ever read…its useful for me as im a lecturer and always motivate my students with these publised stories…thank you …and waiting for plenty more…
Thank. It makes me feel great when I read all these stories. It helps me from hopelessness and make me more stronger to fly… thank… for everything. Love