Jump to content

Table Header Styling


Go to solution Solved by possien,

Recommended Posts

I have some basic CSS that sets the defaultstyle for all table headers.

table th {
	   padding-top: 9px;
	   font-weight: bold;
	   vertical-align: middle;
	 }	
	

I also have another table in a report output that i want the headers to be a slightly different. so i thought i would create a class for them since they will appear 4 times in the report. This is what i tried.

table th .formheader {
			text-align: center
			font-size: 1.5em;
		     }

And here is the html:

<tr>
<th colspan="2" class="formheader">Insurance Info</th>
</tr>

And ive attached a screenie of what it looks like but essentially its not taking the formheader stuff. Im sure i am overlooking something stupid as i am still new to this. Please assist?
Thanks for looking.

post-167300-0-47580500-1391283866_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/285866-table-header-styling/
Share on other sites

  • Solution

You might try this:

 

th {
     padding-top: 9px;
     font-weight: bold;
     vertical-align: middle;
     }

.formheader {
text-align: center;
font-size:1.5em;
 }
 
just create a class called .formheader.  You forgot the semi-colon after the text-align: center .  The th tag is a decendent of the table tag so you don't need to reference it in css.  You are only styling the th.

 

table th .formheader {
			text-align: center
			font-size: 1.5em;
		     }
... Im sure i am overlooking something stupid as i am still new to this. Please assist?

 

The reason what you tried doesn't work is because of the space between th and .formheader. With the space it is looking for an element with class .formheader that is a descendant of a th element, for example:

<th><span class="formheader">Blah</span> Blah</th>
In order for it to seek a th which itself has the .formheader class you need to remove the space, eg:

table th.formheader
As mentioned though, using the table tag, and a th prefix on the class is likely unnecessary unless you need that level of specificity to overcome previous rules.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.