mirror of
https://github.com/clagnut/webtypography.git
synced 2025-09-09 12:40:49 +02:00
cleaning up CSS example code
This commit is contained in:
@@ -13,28 +13,43 @@
|
||||
<p>This is a table of contents so it has been marked up as a simple table:</p>
|
||||
|
||||
<pre><code><table>
|
||||
<tr><th>Introduction</th>
|
||||
<td>7</td></tr>
|
||||
<tr><th>Chapter <strong>1</strong>
|
||||
The Sex of Centaurs</th><td>11</td></tr>
|
||||
<tr><th>Chapter <strong>2</strong>
|
||||
Poliphilo&#8217;s Dream</th><td>11</td></tr>
|
||||
<tr>
|
||||
<th>Introduction</th>
|
||||
<td>7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Chapter <strong>1</strong>
|
||||
The Sex of Centaurs
|
||||
</th>
|
||||
<td>11</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Chapter <strong>2</strong>
|
||||
Poliphilo&#8217;s Dream
|
||||
</th>
|
||||
<td>11</td>
|
||||
</tr>
|
||||
</table></code></pre>
|
||||
|
||||
<p>The <abbr title="Cascading Style Sheets">CSS</abbr> looks like this:</p>
|
||||
|
||||
<pre><code>table {
|
||||
margin: 0 3em 0 auto; }
|
||||
margin: 0 3em 0 auto;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: normal;
|
||||
text-align: right;
|
||||
padding:0; }
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
td {
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
padding: 0 0 0 0.5em; }</code></pre>
|
||||
padding: 0 0 0 0.5em;
|
||||
}</code></pre>
|
||||
|
||||
<p>While most of the <abbr title="Cascading Style Sheets">CSS</abbr> is straight forward, a point worth highlighting is the <code>margin</code> declaration for the <code>table</code> itself. There is a right margin of 3 em to set the table in slightly from the right gutter and a left margin of <code>auto</code> to push the table over towards the right hand side of the page.</p>
|
||||
|
||||
@@ -61,21 +76,25 @@ td {
|
||||
<p>The <abbr title="Cascading Style Sheets">CSS</abbr> looks like this:</p>
|
||||
|
||||
<pre><code>table {
|
||||
margin: 0 auto; }
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: normal;
|
||||
text-align: right;
|
||||
padding: 0 0.5em 0 0; }
|
||||
padding: 0 0.5em 0 0;
|
||||
}
|
||||
|
||||
td:before {
|
||||
content: "2022";
|
||||
padding-right: 0.5em; }
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
td {
|
||||
font-style: italic;
|
||||
text-align: left;
|
||||
padding: 0; }</code></pre>
|
||||
padding: 0;
|
||||
}</code></pre>
|
||||
|
||||
<p>There a couple of points worth noting in the <abbr title="Cascading Style Sheets">CSS</abbr>. The table has been centered by giving the left and right margins a value of <code>auto</code>. For block-level elements a <code>width</code> declaration would also be required when applying this technique, however tables have an inherent width so one does not need to be specified explicitly.</p>
|
||||
|
||||
|
Reference in New Issue
Block a user