Is there a better way ? Even though this works

First off this works and displays as it should, but I suspect I should not have to use “minus padding” to get it to do so. I guess I would be better changing the measurements from px to % for those who have a different font or text size. Though I know I cannot specify a %age for minus padding.

Is there a better way?

http://www.c5d.co.uk/kimmeridge1911.php (Specific HTML) It’s after the first entry

HTML:

 <tr>
<td colspan=5 rowspan=6><p class="table1911alignleft"><br>I certify that:—<br>
(1.) All the ages of this Schedule are entered in the proper sex columns.<br>
(2.) I have counted the males and females in Column 3 and 4 separately,</p>
and have compared their sum with the total number of persons.<br>
<span class="minuspadding12">(3.)</span> After making the necessary enquiries I have completed all the entries on<br>
<span class="indent5">the</span> Schedule which appeared to be defective, and have corrected<br>
<span class="padding191120">such as appeared to be erroneous.</span><br>
<p class="indent12">Initials of Enumerator      G.E.B</p></td>
  <td class="nbl" colspan=3><p class="statscenter">TOTALS</p></td>
  <td class="nbat" colspan="7"></td>
 </tr>

CSS:

.table1911alignleft {
text-align:left;
margin:0;
padding-left:10%;
}

.minuspadding12 {
margin-left:-12px;
}

.indent5 {
padding-left:5%;
 }

.indent12 {
padding-left:12%;
 }

.padding191120 {
padding-right:25%;
 }

.statscenter {
text-align:center;
margin:0;
}

Off Topic

@certificates: when you post code here, you need to format it so that it will display correctly.

You can highlight your code, then use the </> button in the editor window, which will format it, or you can place three backticks ``` (top left key on US/UK keyboards) on a line before your code, and three on a line after your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

Thanks for that, and for editing it. I shall remember for a future occasion

1 Like

Hi,

There is no such thing as negative padding but I think you meant negative margin anyway :slight_smile:

As with all these layouts you need to think of semantics first and as you have a list of items a list is the correct element to use.

With a careful structure you can avoid all the miscellaneous padding/margins and magic numbers (which by the way don’t line up in your page) and simply let the html and css do the heavy lifting for you.

I would go about it like this:

The code could be dropped straight into your cell.

2 Likes

I think we’ve been here before.

You may want to check the validation, it’s giving 178 errors. :frowning:

1 Like

Thanks for that.

What you have given me is far too advanced for me. and I shall have to try and understand it

It works perfectly though, and I have put it place.

I did mean negative margin.

Thanks very much. Maybe I should ask you to look at the other box on the right hand side with the signatures and addresses

I have become confused now because as far as I can tell my tables are all validly constructed yet the validator tells me there are 93 error each regarding nothing n the cells

Am I missing something?

https://html5.validator.nu/?doc=http://www.c5d.co.uk/kimmeridge1911.php

Empty rows, <tr></tr>, in HTML tables are pointless, they don’t do anything at all except fail validation.

Why did you include them? What were they supposed to be doing?

1 Like

But they are not really empty,

The rowspans just make it look that way

In its simplest form rowspan=2 rowspan=3
rowspan=3 rowspan=2

You would still need three tr /tr or the table is invalid

I’ve updated the codepen with an example:

The only complicated part was the CSS counters but that had nothing to do with the way it was laid out and could simple be replaced with numbers as in your version.

The layout works by using inline-block which can be used to center the whole thing in the available space. The box will be as wide as its longest line of text.

The centred lines in each item are created using spans which are set to display:block to bring then to a new line and then text-align:center to center them.

This keeps the whole lot aligned together as required.

Using breaks to break lines is not semantic unless it is a natural break in the line such as lines in a poem. For text that you want visually to appear on the next line but not to actually be another line of text then you should use css to create the visual appearance. A break is a an html element that usually means the line has ended and a new line started. It is not a means to split a line of text at some arbitrary point and as such should seldom be used in paragraphs. It is mostly used in poems to create a new line.

The sentence you have is one sentence that does not have a pause (or break) in its logic and is read as one sentence. Therefore a span is used which infers no semantic meaning to the text and the required visual display is handled silently through css. The meaning of the text is therefore untouched and as expected. Html provides the structure and css provides the visual that you require without harming the semantics of the html.

2 Likes

Thank for that. It’ really is helpful. Can I ask will it work as is for all the entries or will I need to do any adjustments because some have longer names than others of course

I have been trying to adapt the first code you gave me so that I could use it in the top left box which begins …of every person, but whilst I can see you have list style none in the CSS it still gives me the 1 & 2 or two dots if I change it to a ul.

of every Person, whether Member of
Family, Visitor, or Servant,
who

(1)passed the night of Sunday April
2nd, 1911, in this dwelling and
was alive at midnight, or
(2) arrived in this dwelling on the
morning of Monday, April 3rd, not
having been enumerated elsewhere.

Initials of Enumerator G.E.B


  </head>
  <body>
<div class="wrap">
  <div class="box">
    <p>of every Person&#44; whether Member of<br>Family&#44; Visitor&#44; or Servant&#44;<br>who</p>
    <ul class="centred-list">
      <li>(1)passed the night of Sunday April<br> 2nd&#44;</span></span> 1911&#44; in this dwelling and<br>was alive at midnight&#44; or</li>
      <li>(2) arrived in this dwelling on the<br>morning of Monday&#44; April 3rd&#44; not<br>having been enumerated elsewhere&#46;</li>
	   </ol>
    <p class="footnote">Initials of Enumerator G.E.B</p>
  </div>
</div>
 
  </body>
</html>
.wrap {
    border:1px solid #000;
    padding:10px;
    text-align:center;
    width:50%;/* just for testing */
  min-width:600px;/* just for testing */
}
.box {
    text-align:left;
    display:inline-block;
    vertical-align:middle;
    text-align:left;
    
}
.box p {
    margin:1em 0 0;
}
.centred-list {
    margin:0;
    padding:0;
    list-style:none;
    counter-reset:section;
    line-height:1.2;
}

.centered-list{list-style-type:none; }

.centred-list li{margin:0 0 1px}
.centred-list li:before {
    counter-increment:section;
    content:"(" counter(section)".)";
    margin-right:5px;
}
.centred-list span {
    text-align:center;
    display:block;
}
p.footnote {
    margin:1.5em 0 1em;
    text-align:center;
}
 

I have copied the additional info you provided about the semantic side, I hope you don’t mind.

They sure look empty to me…
(lines 423-428) (first of many)

 <tr>
 </tr>
 <tr>
 </tr>
 <tr>
 </tr>

The first of many; Yes there are 31 because each is the same

'm confused because the table checked doesn’t identify them. Just 1 can’t spot

HTML table checker online

http://cerebrumcontorquet.debun.nl/brainwaves/tablecheck/index.php

url=http://www.c5d.co.uk/kimmeridge1911.php

Result:

10821 lines checked for table code errors.
1 table error(s) found.
Error on line 402: illegal after .

Done

try-again

105: table (0 deep)
107: tr
108: td
113: /td
114: /tr
115: tr

Try this checker:-
https://validator.w3.org/nu/?doc=http%3A%2F%2Fwww.c5d.co.uk%2Fkimmeridge1911.php

I used that via firefox which is why I am confused,

I even re imported the table back into excel and it looks fine still

I think it is something to do with these six columns which despite the image are each in one cell, one wide and one deep

which are surrounded by columns of more than one row

You start as a ul and you end as an ol ?

ul stands for Unordered list but you clearly have an Ordered List ‘ol’. :slight_smile:

1 Like

Sorry, I keep trying to get it to work

If I use one, I get numbered line, if I use the other I get bullets

And if you use both to start and end the same list, you write bad code and get a validation error.

:shrug:

1 Like

I know, which i why I haven’t implemented it. You seem to developed an acerbic wit of late, I have seen some of your responses to others, I like it and it makes me smile

It should work for all within reason.

It should not be a ul but an ol as I mentioned above. The numbers are being added by the css counters rule and you do not need to add them manually. Thjis means that if at a later date you ad or remove or insert entries the numbers will still be uniformly correct. Imagine if you had a hundred entries and you wanted to remove one entry in the middle! You would then need to manually change all the numbers from 1 - 99. The css counters does this automatically.

3 Likes