| 1 |
Differences to the `html4css1` Writer |
| 2 |
===================================== |
| 3 |
|
| 4 |
* Use only meta_ keywords recognized by HTML 5. |
| 5 |
Add HTML5-compatible meta tags for docinfo items |
| 6 |
"authors", "date", and "copyright". |
| 7 |
|
| 8 |
Add a `viewport meta tag`__ to tell mobile browsers |
| 9 |
to use the device-width as viewport. |
| 10 |
|
| 11 |
__ https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag |
| 12 |
|
| 13 |
* Set table column widths with <style="width: ...">, not "width" argument. |
| 14 |
|
| 15 |
* Horizontal alignment of table heads with CSS. |
| 16 |
|
| 17 |
* Do not drop paragraph elements, use CSS rules to prevent unwanted vertical |
| 18 |
space. |
| 19 |
|
| 20 |
* Put subtitles in <p> elements. |
| 21 |
|
| 22 |
* Use the new semantic tags <main>, <section>, <header>, |
| 23 |
<footer>, <aside>, <figure>, and <figcaption>. |
| 24 |
See ``minimal.css`` and ``responsive.css`` for styling rule examples. |
| 25 |
|
| 26 |
Change the `initial_header_level` setting default to "2", as browsers |
| 27 |
use the `same style for <h1> and <h2> when nested in a <section\>`__. |
| 28 |
|
| 29 |
__ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article |
| 30 |
|
| 31 |
* Use HTML5 tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>, |
| 32 |
<i>, <b>, <u>, <mark>, and <bdi> if a matching class value |
| 33 |
is found in `inline` and `literal` elements. |
| 34 |
Use <ins> and <del> if a matching class value |
| 35 |
is found in `inline`, `literal`, or `container` elements. |
| 36 |
(See `text-level semantics`_ and `indicating edits`_.) |
| 37 |
|
| 38 |
* Use <img> tags for SVG images and <video> for video formats. |
| 39 |
|
| 40 |
* .. image:: ../input/data/blue%20square.png |
| 41 |
:loading: embed |
| 42 |
:alt: blue square |
| 43 |
:align: right |
| 44 |
|
| 45 |
Embed images or defer fetching images with the image-loading_ |
| 46 |
configuration setting or the "loading" option of the "image" directive. |
| 47 |
|
| 48 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 49 |
:loading: lazy |
| 50 |
:width: 16 |
| 51 |
:height: 16 |
| 52 |
:align: right |
| 53 |
|
| 54 |
Especially with "lazy" loading, it is strongly recommended to |
| 55 |
specify both width and height of the image to prevent content layout |
| 56 |
shifts or use the "scale" option to let the writer insert the size |
| 57 |
determined from the image file. |
| 58 |
|
| 59 |
.. _image-loading: |
| 60 |
https://docutils.sourceforge.io/docs/user/config.html#image-loading |
| 61 |
|
| 62 |
|
| 63 |
Field List Rendering |
| 64 |
-------------------- |
| 65 |
|
| 66 |
A `field list` is converted to a HTML `definition list` and given the |
| 67 |
``field-list`` class argument value to allow CSS styling. |
| 68 |
With ``html_plain.css``, the layout is similar to `html4css1`: |
| 69 |
|
| 70 |
.. class:: open |
| 71 |
|
| 72 |
:A long field name: sticks into the field body. |
| 73 |
|
| 74 |
The field body is pushed to the next line (you can suppress this |
| 75 |
behaviour with the `run-in`_ class argument). |
| 76 |
|
| 77 |
:Customization: of the field name width is possible with CSS instead |
| 78 |
of the `field-name-limit` configuration setting, for |
| 79 |
example:: |
| 80 |
|
| 81 |
dl.field-list > dd { margin-left: 6em; } |
| 82 |
|
| 83 |
:Empty: |
| 84 |
|
| 85 |
:fields: must not lead to misalignment of the following content. |
| 86 |
|
| 87 |
Styling with Class Arguments |
| 88 |
---------------------------- |
| 89 |
|
| 90 |
The ``plain.css`` style sheet comes with some pre-defined style variants |
| 91 |
that can be chosen via a class argument. |
| 92 |
|
| 93 |
Description Lists |
| 94 |
````````````````` |
| 95 |
|
| 96 |
Definition lists with the "description" class argument: |
| 97 |
|
| 98 |
.. class:: description |
| 99 |
|
| 100 |
description lists |
| 101 |
Definition lists that are styled like in most dictionaries, |
| 102 |
encyclopedias etc. (as well as the LaTeX `description` environment). |
| 103 |
label |
| 104 |
The term to be described. Put in boldface or italic. |
| 105 |
Content |
| 106 |
starts on the same line and has a hanging indent. |
| 107 |
A label without content |
| 108 |
.. |
| 109 |
and the next label |
| 110 |
must align. |
| 111 |
|
| 112 |
as well |
| 113 |
as content containing more than one |
| 114 |
|
| 115 |
paragraph |
| 116 |
|
| 117 |
or |
| 118 |
* nested lists |
| 119 |
* item 2 |
| 120 |
or |
| 121 |
nested |
| 122 |
definition lists |
| 123 |
|
| 124 |
Details disclosure elements |
| 125 |
``````````````````````````` |
| 126 |
|
| 127 |
Items of `definition lists`_ with class argument "details" are converted |
| 128 |
to `details`_ disclosure elements with the term becoming the "summary". |
| 129 |
|
| 130 |
.. _closed-details: |
| 131 |
.. class:: details |
| 132 |
|
| 133 |
A summary |
| 134 |
with details only visible after user interaction. |
| 135 |
|
| 136 |
.. _open-details: |
| 137 |
.. class:: details open |
| 138 |
|
| 139 |
Another summary |
| 140 |
with open details because the source list has the additional class |
| 141 |
value "open". |
| 142 |
|
| 143 |
.. _details: |
| 144 |
https://www.w3.org/TR/html52/interactive-elements.html#the-details-element |
| 145 |
|
| 146 |
Field List Variants |
| 147 |
``````````````````` |
| 148 |
|
| 149 |
For field lists, the "compact/open", "narrow" and "run-in" styles are defined |
| 150 |
in the style sheets ``plain.css`` and ``responsive.css``. |
| 151 |
|
| 152 |
*compact* |
| 153 |
.. class:: compact |
| 154 |
|
| 155 |
:Feature: No additional space between list items. |
| 156 |
|
| 157 |
:Option: The ``--compact-field-lists`` command line option (and the |
| 158 |
corresponding configuration setting) set the `compact` |
| 159 |
class argument on all "simple" field lists, if not |
| 160 |
overridden with `open`. |
| 161 |
|
| 162 |
:Use: For lists with short field body. |
| 163 |
|
| 164 |
*open* |
| 165 |
.. class:: open |
| 166 |
|
| 167 |
:Feature: Additional space between list items also in "simple" lists. |
| 168 |
(Overrides the ``--compact-field-lists`` command line |
| 169 |
option and the corresponding configuration setting) |
| 170 |
|
| 171 |
:Use: For "simple" lists that should keep the space between list items. |
| 172 |
|
| 173 |
*narrow* |
| 174 |
.. class:: narrow |
| 175 |
|
| 176 |
:Feature: Less indented field body. |
| 177 |
:Use: For lists with short field names. |
| 178 |
:A long field name: |
| 179 |
sticks into the field body and the field body starts on a |
| 180 |
new line (if not combined with `run-in`_). |
| 181 |
|
| 182 |
custom *field-indent* |
| 183 |
.. class:: field-indent-3em |
| 184 |
|
| 185 |
:Feature: Field body indented by custom amount. |
| 186 |
:Use: class value starting with ``field-indent-`` followed by |
| 187 |
a valid length, e.g. ``field-indent-3em``. |
| 188 |
:The writer: |
| 189 |
will convert this class value to a ``style`` attribute setting. |
| 190 |
|
| 191 |
.. _`run-in`: |
| 192 |
|
| 193 |
*run-in* |
| 194 |
.. class:: run-in |
| 195 |
|
| 196 |
:Feature: Field body starts on the same line also after long field |
| 197 |
names. |
| 198 |
|
| 199 |
:A long field name: sticks into the field body which continues on |
| 200 |
the same line. |
| 201 |
|
| 202 |
:The next field name: and field body should align. Long text in the field |
| 203 |
body is wrapped and aligns with other fields. |
| 204 |
|
| 205 |
Table Variants |
| 206 |
`````````````` |
| 207 |
|
| 208 |
The following styles can be applied to individual tables via a class |
| 209 |
argument or as document wide setting with the table-style_ configuration |
| 210 |
setting (or command line argument). |
| 211 |
|
| 212 |
* Numbered tables can be achieved with the "numbered" class option: |
| 213 |
|
| 214 |
.. table:: truth values |
| 215 |
:class: numbered |
| 216 |
|
| 217 |
======= ======= ========== |
| 218 |
A B A or B |
| 219 |
======= ======= ========== |
| 220 |
False False False |
| 221 |
True False True |
| 222 |
False True True |
| 223 |
True True True |
| 224 |
======= ======= ========== |
| 225 |
|
| 226 |
Currently, referencing to the table by number is not supported. This is a |
| 227 |
common request and already on the `TODO list`. |
| 228 |
|
| 229 |
* A table with "booktabs" class value, is rendered similar to the style |
| 230 |
from the booktabs_ LaTeX package. |
| 231 |
|
| 232 |
.. _table-style: |
| 233 |
https://docutils.sourceforge.io/docs/user/config.html#table-style |
| 234 |
.. _booktabs: |
| 235 |
http://tug.ctan.org/tex-archive/macros/latex/contrib/booktabs/booktabs.pdf |
| 236 |
|
| 237 |
"Booktabs" style table, numbered, centre-aligned, with auto-sized columns: |
| 238 |
|
| 239 |
.. table:: I/O values |
| 240 |
:class: booktabs numbered |
| 241 |
:align: center |
| 242 |
:widths: auto |
| 243 |
|
| 244 |
======= ======= ========== |
| 245 |
Input Output |
| 246 |
--------------- ---------- |
| 247 |
A B A or B |
| 248 |
======= ======= ========== |
| 249 |
False False False |
| 250 |
True False True |
| 251 |
False True True |
| 252 |
True True True |
| 253 |
======= ======= ========== |
| 254 |
|
| 255 |
Numbered Figures |
| 256 |
```````````````` |
| 257 |
|
| 258 |
Numbered figures can be achieved with the "numbered" ``:figclass:`` option: |
| 259 |
|
| 260 |
.. figure:: ../../../docs/user/rst/images/title-scaling.svg |
| 261 |
:alt: reStructuredText, the markup syntax |
| 262 |
:figclass: numbered |
| 263 |
:width: 100% |
| 264 |
:loading: embed |
| 265 |
|
| 266 |
Embedded SVG image in a numbered figure. |