Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

H1 Vertical align middle

Posted on 2004-08-12
3
Medium Priority
?
1,462 Views
Last Modified: 2008-02-01
Hello

can anyone help solve this problem, i'm trying to align the h1 element so that it appears in the center of the th cell, but i cannot seem to get it to work. I have supplied the code below.
// header cell
#CouCssHPT TH {
      background-color: #A9B9D1;
      color: #191970;
      border: 1px solid #A9B9D1;
      padding: 5px;
}

Div#HeaderBorder {
      background-color: transparent;
      color: #191970;
      padding: 3px;
      border: 1px solid White;
      width: 95%;
}

Div#HeaderBorder h1 {
      background-color: transparent;
      color: #191970;
      font-family: Arial, Helvetica, sans-serif;
                font-size: 100%;
      font-weight: bold;
      vertical-align: middle;
      text-align: center;
}

<th colspan="3"><div id="HeaderBorder"><h1>Book review</h1></div></th>

Thank You
Caz
0
Comment
Question by:BeginningWebDesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
mreuring earned 2000 total points
ID: 11790889
This should work:
#CouCssHPT TH {
     background-color: #A9B9D1;
     color: #191970;
     border: 1px solid #A9B9D1;
     padding: 5px;
     vertical-align: middle;
}

Div#HeaderBorder {
     background-color: transparent;
     color: #191970;
     padding: 3px;
     border: 1px solid White;
     width: 95%;
}

Div#HeaderBorder h1 {
     background-color: transparent;
     color: #191970;
     font-family: Arial, Helvetica, sans-serif;
      font-size: 100%;
     font-weight: bold;
     text-align: center;
       display:inline;
}

I placed the vertical-align on the th instead of the h1 and added the display: inline to the h1 to make it normal text, which is then governed by it's parent.

Hope this helps,

  Martin
0
 

Author Comment

by:BeginningWebDesign
ID: 11790927
Hi Martin

Thanks what does the: display: inline do?

Caz
0
 
LVL 17

Expert Comment

by:mreuring
ID: 11790976
Based on minimal support (being IE) display can set a few modes block, inline, list-item and none. There's a fair few others but those are mostly irrelevant or not supported in IE and hence mostly useless in a commercial site.
- none: Don't display this element or anything it contains
- inline: This element and it's containers are text. This means not principal block is generated the content is really just text.
- block: Generate a principal block. A box is generated, just picture the contents as having a square fence. Block elements are not considdered text and are not affected by alignments of text.
- list-item: Generates a box with a preceding box containing a marker.

Like I mentioned a block element does not listen to text-align (or vertical-align for that matter) of it's parent. Also it generates , by default, a box which is just large enough to contain it's contents. In your situation you needed the text of the h1 to be centered vertically according to the size of your th. The easiest way to go about doing this was to stop the h1 from generating it's own block, in order to do this you set it to inline and it becomes just another line of text, which does listen to the vertical-align of the th.

It's a concept I find hard to explain, so I hope this was clear enough :)

 Martin

btw, for the specs: http://www.w3.org/TR/CSS2/visuren.html#propdef-display
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question