Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


How do I tuck my corporate motto under my site name in CSS?

I'm trying to get my company motto tucked right under my site URL in my header using CSS and can't quite get it right. I tried <h4> </h4> instead of <p></p>. Motto is showing up above domain name, still having trouble getting motto under domain name. Here's my code:

<div id="header">
  <div id="logo">
    <h1><a href="#">mywebsite.com</a></h1><br />
    <p><i>My motto here.</i></p>
  </div>
</div>

and I have a bunch of complicated CSS, but it just isn't working. Help!


Dave's Answer:

No, the CSS positioning that you have in your style is going to mess things up, coupled with the spacing that the h4 and p tags force on your layout too. I would skip the h1 and p and I and use CSS instead. Like this:

<div id="header">
  <div id="logo">
    <a href="#">mywebsite.com</a>
  </div>
  <div id="motto">
    your witty motto
  </div>
</div>

Now, in your CSS you can do something like this:

<style type="text/css">
#logo { font-size:175%; font-color:#333; font-family: sans-serif; padding-top: 8px;
  padding-bottom: 1px; margin-bottom: 1px; }
#motto { font-size:120%; font-color:#333; font-family: sans-serif;
  padding-bottom: 8px; padding-top: 1px; margin-top: 1px; }
</style>

See what I'm doing? Let the CSS do all the spacing and line height work and you'll find that you have complete control over your spacing. Further, recall that margin AND padding control the space around the contents of a container like "div", so you need to tweak it below the top one AND above the bottom one.

Try that, see if it helps you get where you want. Note, however, that if you make your URL clickable then you have a more complicated issue with formatting because you can't just use the formatting in the ID, but need to touch the style itself. Quite doable, but more tricky...


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  





Categorized: HTML, JavaScript and Web Site Programming   (Article 7706, Written by )
Tagged: css, page layout, style sheets
Previous: How do I find a driver for my Sony MP3 player?
Next: Is syndicating my blog postings a recommended tactic?




Reader Comments To Date: 1

Damien Le Berrigaud said, on November 27, 2007 12:55 AM:

You should use h1 and h2 instead of divs. It is more semantic and can give the same result.

<div id="header>
  <h1>Title</h1>
  <h2>Subtitle</h2>
</div>

then in ou stylesheet use the following selectors: #header h1, and #header h2. You shouldn't need #header if you correctly use h3, h4, h5, h6... for the next titles in your site.

You may have to reset margin and padding of h1 and h2 and other elements to zero before setting your own as different web browsers behave differently with default values...

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.