5 Little Known Way to CSS Styling Your Blog

by Yan Susanto

Let me just say this is supposed to be the second part of What You Need To Know About CSS – The Basic which I wrote a couple of days ago. Today I’ll like to share with you a couple of CSS Styles you’ve probably know little about.

As we all know it, CSS controls the appearance and layout of your whole blog. As such a little CSS tweak may sometimes be needed to improve your theme design and enhance your users browsing experience.

5 CSS Tips to Improve Your Blog

Styling your blog has never been easier now if you are familiar with editing and modifying your Style Sheet. Below is 5 of the CSS tips you could adopt (the one I’m using) to improve the visual appearance of your blog.

1. CSS reset

The idea to reset your CSS is to tackle the issue of cross-browser inconsistency which may make your blog quiet different in layout from one browser to another. Have you ever noticed your blog layout may not look quiet you want in IE? Oh I hate IE. Therefore it is important to reset your CSS before you attempt to pimp your blog. Based on Eric Meyer’s Global CSS Reset, here’s my reset styles



body,
h1, h2, h3,
p, ul, li,
blockquote, pre, code,
form, img {
	border: 0;
	margin: 0;
	padding: 0;
	outline: 0;
	}

You can grab a copy of Eric Meyer’s CSS Reset to use and tweak as fits you best.

2. line-height

What is line-height, as it is called in CSS? It is the area within the lines. I guess this is one area where most people tend to forget to define. Your post content should be made easy to read for your readers. Similarly so, a paragraph when proper line-height is taken care of should not strain the eyes.

How about this? What is line-height, as it is called in CSS? It is the area within the lines. I guess this is one area where most people tend to forget to define. Your post content should be made easy to read for your readers. Similarly so, a paragraph when proper line-height is taken care of does not strain the eyes.

Which one do you prefer? It’s quiet obvious, isn’t it? So don’t let your visitors click away, set your line-height properly, will you?



#content {
	line-height : 1.8em;
	}

3. float

floatIf you are using WordPress 2.5 image uploader tool, you can insert and define with a few clicks the position of your image either to the right or left of your text paragraph.

For example, when you insert an image directly into your post, like the image on the left, you will have HTML tags like this

float

Let’s put some style to image class by adding float element for better image positioning and margin value to it to prevent the image sticking to the text.



img.alignleft {
	float: left;
	margin-right: 10px;
	}

img.alignright {
	float:right;
	margin-left: 10px;
	}

The margin-left and margin-right is to create the white space of 10px between the image and your text when you position or float your image either to the left or right respectively.

4. overflow: hidden

This basically tells the browser to hide any long overflowed content, an over-sized image or pretty long text link for instance, which would otherwise screw up and break your blog design. You wouldn’t want it to happen, would you?



#content {
	overflow: hidden; /* Prevent oversized content to break */
	}

5. text-align

Whether to align your text paragraph to the left, right or justify, it’s really up to your own individual preference. However, I prefer it to be justified to create a better and neater style of presentation. Don’t you agree with me?



#content {
	text-align: justify;
	}

I haven’t been long enough playing with CSS to understand the reason why a lot of people still prefer to align the text to the left. Would somebody explain it to me?

What have you got to say? What other CSS tips and tricks that you know of that will improve the accessibility and readability of your blog? I’m sure there are a couple of hundred things you can do improve the visual layout your blog using CSS, so let me know your suggestion by leaving your comments below.

Related posts

Sponsor of The Month

{ 8 comments }

drt June 2, 2008 at 11:48 pm

Wish you put a sample usage. Ok, let’s say I have added the align left/right to my css code, then how do I implement the code if I want to place an image floating 5 px on the left side? I know, I should check the css tutorial, but since you’re targeting a general audience, I think adding some examples would really help. Thanks.

Yan June 3, 2008 at 12:21 am

@ drt: Thank you for your suggestion. May I ask if the code example is not sufficient enough?

Perhaps you are referring to how to edit the theme CSS. For that, I have mentioned in the beginning of the post that this is the second part of the Basic CSS where I did attempt to explain the ‘how-to-implement’.

Rhys June 3, 2008 at 11:16 am

Nice post Yan!

I believe that align-left is a hangover from the long English composition tradition of starting new lines at the left margin.

BTW – I hoped to see CommentLuv in action by now. Did you decide to not use it??

Yan June 3, 2008 at 11:35 am

@Rhys: Good to see you again and your gravatar helps me to easily recognize you.

LOL. I was not born speaking English to learn the history of align-left. I guess if WordPress uses it, then it’s all good.

With regard to CommentLuv, yes it is in my to-do list but I’m just not too good with prioritizing. You’ll see it in action soon, I promise.

Alex June 4, 2008 at 8:52 pm

Yan,

Great tips on what I think perhaps the hardest technical aspect for many bloggers. CSS allows us so easily change aspects of the look and feel of the theme used and separate blog appearance from the rest and yet many simply can’t do that due to the fear of working with css.

Your tips should help many :D

Alex’s last blog post..Explode Your Blog With Dynamic Force

Yan June 4, 2008 at 10:26 pm

@Alex: You are right. Many fear to go beyond the dashboard to experiment with different CSS styles. I hope I could help a little bit here.

Hey, thanks for dropping by. I appreciate your sharing your opinions on the subject. If you do have anything to add, feel free to let me know.

Cactii June 18, 2008 at 2:05 pm

Thanks for the help with the CSS – it can sure be confusing sometimes when you have a fairly complicated layout.

The overflow: hidden is a great tag. ;)

Cactii’s last blog post..GPS Tracking Systems for Cars, Pets and People

Yan June 18, 2008 at 4:25 pm

@Cactii: Glad the tips can be of help to you and thanks for stopping by. Do check also Yet Another 8 CSS Tips For Your Blog.

{ 2 trackbacks }

Previous post:

Next post: