WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You

WebArtz - The Web Design Forum
Welcome to WebArtz, Guest!

WebArtz is a nice place for discussions related to web designing and coding. We help our members to code their own website templates with HTML and CSS. We give them advice on various issues.

To know more about WebArtz Forum, visit the About Us page.

At the moment, you are viewing the forum as a guest. As a guest you can't make post and participate in discussions. You need to register and become a member of the forum. Click the register link below and become a part of this forum.

Thank You


You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1Accespted Aligning text with CSS Mon Dec 13, 2010 9:02 pm

Guest


Guest
Aligning text with CSS
Aligning text horizontal and vertical


Some times in website design, some of the most basic requirements can leave us pondering for a moment, so little snippets of wisdom here and there are what help us strive toward the better technique in the long run.

When it comes to aligning text we should without doubt be looking to do this using CSS, ensuring that we avoid using any inline styles. This can be used to align text both horizontally and vertically.

Horizontal align

In order to centre the text in a particular div horizontally, we can use the following CSS on either text tag it’s self or the containing parent div. Both will give us the simple and desired effect of horizontal alignment.
Code:
{ text-align:center; }

Vertical Align

Out of the two examples mentioned, it’s this one that often leaves people a little stumped. Back in the days of using tables, this function seemed to be taken for granted with the ‘valign’ selector readily on hand.

This effect by setting padding of equal proportion seems to be effective, but aside from playing up when it comes to cross browser compatibility, there’s quite simply, an easier way.
Code:
{ line-height:40px; }

This will set the height of the tag or div to 30 pixels whilst ensuring that your text remains in the centre on all browsers and regardless of text size.

Notice : This tutorial is copyrighted by WebArtz Forum. You may not publish it on anywhere without written permission from the administrators.

2Accespted Re: Aligning text with CSS Sat Dec 18, 2010 9:56 pm

ankillien

ankillien
Administrator
Administrator
Nice one Very Happy

Tutorial Accepted

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum