How do I put this inline style into a external style sheet

web page: www.c5d.co.uk/1871.php

Style sheet currently is www.c5d.co.uk/censusstyle.css

table named tableheader1861

After entry number 6 is this :

<table class="tableheader1861">
    <tr>
	<td colspan="8"><div style="margin-left:25px;"></div>Page 2 ]<div style="text-align: center; display: inline; padding-left:500px;">The undermentioned Houses are situate with the Boundaries of the<span style="text-align: right;"><br>&nbsp;</span></div> </td>
 </tr> <tr>
     <td><p class="censusalignment">*Civil Parish [<span class="strike">or Township</span>] of</p></td>
     <td><p class="censusalignment"><span class="strike">City or<br>Municipal Borough of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Municipal Ward of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Parliamentary Borough of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Town of</span></p></td>
     <td><p class="censusalignment">Village <span class="strike">or Hamlet&amp;c, of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Local Board or [Improvement<br>Commissioners District] of</span></p></td>
	 <td><p class="censusalignment"><span class="strike">Ecclesiastical District of</span></p></td>
  </tr>
  <tr>
     <td><p class="statscenter">Kimeridge</p></td>
     <td></td>
     <td></td>
     <td></td>
     <td></td>
     <td><p class="statscenter">Kimeridge</p></td>
     <td></td>
	 <td><p class="statscenter">Kimeridge</p></td>
  </tr>
  </table>

What I should ideally like is page 2 on the left margin with an indentation of 10 px
All cell heights to be the same as those above as in the those for the entry number 6.

I have spent 4 hours so far and just can’t seem to get it to work

If it’s easy could the height of the very top row be adjusted too. The HTML i have for that is

    <tr>
	 <td colspan="8"><div style="float: right"><span style="padding-right:10px;">Page 1</span></div><div style="text-align: center">The undermentioned Houses are situate with the Boundaries of the</div> </td>
 </tr> <tr>
     <td><p class="censusalignment">*Civil Parish [<span class="strike">or Township</span>] of</p></td>
     <td><p class="censusalignment"><span class="strike">City or<br>Municipal Borough of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Municipal Ward of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Parliamentary Borough of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Town of</span></p></td>
     <td><p class="censusalignment">Village <span class="strike">or Hamlet&amp;c, of</span></p></td>
     <td><p class="censusalignment"><span class="strike">Local Board of[Improvement<br>Commissioners District] of</span></p></td>
	 <td><p class="censusalignment"><span class="strike">Ecclesiastical District of</span></p></td>
  </tr>
  <tr>
     <td><p class="statscenter">Kimeridge</p></td>
     <td></td>
     <td></td>
     <td></td>
     <td></td>
     <td><p class="statscenter">Kimeridge</p></td>
     <td></td>
	 <td><p class="statscenter">Kimeridge</p></td>
  </tr>

Thanks

Antony

When you post code, PLEASE put
[color=blue][noparse]

[/noparse][/color]
all of your code here
[color=blue][noparse]

[/noparse][/color]
tags around it.

The “#” button in the Quick Reply menu will type them for you. All you have to do is put your code between them.

The code is much easier to read and takes up less vertical space in a post.

Please use the code tags.

To move inline styles to a stylesheet, one must be able to reapply those styles from whence they came.

One common way of doing that is to assign the same classname to the tag and the styles. For example:


<div style="margin-left:25px;"></div>

might become


.tableheader1861 .custom1 {
    margin-left:25px;
}


<div class="custom1"></div>

and


<div style="text-align:center;display:inline;padding-left:500px;">

might become


.tableheader1861 .custom2 {
    text-align:center;
    display:inline;
    padding-left:500px;
}


<div class="custom2">

The choice of appropriately descriptive classnames is up to you.
Because the styles are being moved from inline with the HTML to the stylesheet, issues of specificity may arise.
Firebug or another developer’s tool is your best friend.

Thanks for your comments.

I have done what I intended to do with this page, but still have one concern.

On the even numbered pages, the phrase that begins "The undermentioned houses… only appears centred because of the application of a left padding.

I have tried to get this to centre naturally, but cannot find any solution.

Can you come up with anything ?

<table class=“tableheader1861”>
<tr>
<td colspan=“8”><span class=“evenpagenumber”>Page 2 ]</span><span class=“evenpagehouses”>The undermentioned Houses are situate with the Boundaries of the</span> </td>
</tr> <tr>

CSS

.tableheader1861 .statscenter {text-align:center; margin:0;}
.tableheader1861 .evenpagenumber { margin-left:10px; }
.tableheader1861 .evenpagehouses {text-align:center;display: inline-block; padding-left:500px;}

Thanks

Good show, Antony, that was very close! That counts in horseshoes!

Move the mouse a tad more to the right before clicking and you’ll be right over the “#” button. THAT’s the CODE tags button! (right next door to the Quote button).

Give it a try.

In the Quick Reply box, click the “#” button. Watch the [noparse]


[/noparse] tags appear! Paste you code between them and win a prize :slight_smile: (ok, I’m teasing about the prize.)

Your code will be in a box with scroll bars and will retain its monospaced formatting.

Is the code in http://www.c5d.co.uk/1871.php still valid? Can I use the code at that URL to discuss a possible solution? In other words, are you using the 1871 code on the 1861 page? (The layouts look the same; nevertheless, I ask.)

Never mind. I just realized that the 1871 page uses 1861 styles. I’ll get back with you shortly.

Thanks for the reply.

The web page is www.c5d.co.uk/1871.php

And the tables are tableheader1861 and table1861 with the tablewrapper which you suggested to keep them all the same width,

I can use the 1861 table for the 1871 census because the information contained in both is practically identical

Antony

Antony,

Add the following CSS to your stylesheet.


.evenpagenumber p,
.oddpagenumber p {
    position:relative;  /* provides the context for the absolutely positioned page numbers. */
    text-align:center;  /* center-aligns the p text */
    padding:0 8em;  /* This reserves space for the page numbers at the ends of the paragraph.  Possibly needed IF the p text becomes wider or the table becomes narrower.  It is not necessary here at this time. */
}
.evenpagenumber span {
    position:absolute;
    left:0;   /* position the even page number against the left edge of the paragraph */
    margin-left:1em;  /* add left margin to the page number inside the left edge of the paragraph */
}
.oddpagenumber span {
    position:absolute;
    right:0;   /* position the odd page number against the right edge of the paragraph */
    margin-right:1em;  /* add right margin to the page number inside the right edge of the paragraph */
}

Add the appropriate classname .evenpagenumber or .oddpagenumber to the <tr> tag. (NOT the <td> tag).
Construct the <td> tag as shown in this general example:


<table>

    <tr class="oddpagenumber">
        <td><p><span>Page 1</span>The undermentioned Houses are situate with the Boundaries of the</p></td>
    </tr>

    <tr class="evenpagenumber">
        <td><p><span>Page 2 ]</span>The undermentioned Houses are situate with the Boundaries of the</p></td>
    </tr>

</table>

I’m pleased to say that this has worked great.

I made one minor adjustment to the CSS and that was to add margin: 0: to these two:

.evenpagenumber p,
.oddpagenumber p

This way the cell remains one line tall and doesn’t have a line break after the two elements.

Thanks once again.

Antony

Excellent. Glad to know that it works for you. Thanks for the feedback. Happy New Year!

BTW - there are no line breaks in that line. The height was being applied by the default paragraph margins. Adding margin:0; was the appropriate tweak. :slight_smile:

Would you be kind enough to let me why know why this happens please ?

I have tried to put this tableheader1861 into other censuses. It has worked fine in 1861 but in 1851, it has given me a problem

The first column of the table expands dramatically after the first page.

It does this even if I just break and re start the table.

The page is www.c5d.co.uk/php

Is it just me ?

According to Firebug, .householder .col1 has a width of 20%, so it’s behaving as designed.

Delete the width assignment for .col1 {width:20%;} and the table will look almost normal.

censusstyle.css (line 449)


.householder .col1 {
    [color=red]width: 20%;[/color]
}

Although you show 11 columns in the CSS, there are no column classes in the HTML, so, except for .col1, they are doing nothing
That’s not necessarily a bad thing. Also, the styles associated with the rotated text in col1 need to be changed to keep it from overflowing the left and right edges of the column (except for the topmost table which fits nicely and will continue to do so).

Try changing these styles to the blue values and see how that works, or just delete them:

censusstyle.css (line 441)


.householder p.rotate1 {
     margin: 0  [color=blue]-.25em;[/color]
     width: [color=blue]4.25em;[/color]
}

These vaues for the rotated text are specific and depend on the size of the text box and the width of the box into which it is to fit after rotation. They cannot be copied and pasted into new cells and expected to work.