H4 Spacing Attributes by CSS

Need technical advice on coding your web pages? Covers HTML, JavaScript, CSS, and some server side technologies. Also the issue of some webpages not displayed well.

Moderator: Don_HH2K

H4 Spacing Attributes by CSS

Postby Don_HH2K » Thu 27 Jan, 2005 9:31 am

I was wondering if I can control the spacing on H4 elements via CSS. Example: I currently have an H4 element used in the following way up at my website:
Image

I'd like to make it look like this:
Image

Is that possible? I'd like to keep the H4 element in place instead of using a SPAN element. Or, if necessary, can I take off the spaces on both the top and the bottom and use a BR element to get the space?

P.S. Sorry for the bad-looking screenshot job, the most advanced (and only) image editor on this machine is MSPAINT.
UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8a6) Gecko/20050111
Laptop: HP Compaq nx6325 - Turion 64 X2 @ 2GHz, 2GB DDR2, 100GB HD, ATI Radeon X300, 15" LCD, Seven Pro
Handheld: Palm Treo 650 - Intel PXA270 @ 312MHz, 10MB RAM, 32MB flash, 2.7" LCD, Palm OS 5.4
User avatar
Don_HH2K
Moderator
Moderator
 
Posts: 5112
Joined: Sun 09 May, 2004 3:59 pm

Re: H4 Spacing Attributes by CSS

Postby Antony » Thu 27 Jan, 2005 10:09 am

dluchini30 wrote:Is that possible? I'd like to keep the H4 element in place instead of using a SPAN element. Or, if necessary, can I take off the spaces on both the top and the bottom and use a BR element to get the space?
Just use [tt]margin-top[/tt] or [tt]margin-bottom[/tt]. For example,
Code: Select all
H4 { font-size: 12px; font-weight: bold; margin-top: 2px; margin-bottom: 5px;}

If you want to control all 4 sides, you can use [tt]margin[/tt]. (Of course [tt]margin-left[/tt], [tt]margin-right[/tt] both work)
Note the syntax of [tt]margin[/tt], if you specify one value, it applies to all 4 edges; two values, first one for top and bottom, second one for left and right; three values, first (top), second (left and right), third (bottom); four values, orders are top, right, bottom, and left.
UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.6 (KHTML, like Gecko) Safari/125.12
User avatar
Antony
diamond member
diamond member
 
Posts: 14509
Joined: Tue 18 Jun, 2002 11:36 pm
Location: Sydney, Australia


Return to Web Design and Page Coding

Who is online

Registered users: Google [Bot], Yahoo [Bot]

cron