5 ms·
Couple more tips for those who /really/ want to slim down their html: - opening <a> tags close the previous <a> tag... but without an href they do nothing. Use
by syrrim 6y ago
Couple more tips for those who /really/ want to slim down their html:
- opening <a> tags close the previous <a> tag... but without an href they do nothing. Use them as if they were closing <a>s to save on slashes
- <select>...<select> is completely equivalent in html to <select>...</select>. Save more slashes this way
- formatting elements won't be closed automatically, they rear their head again like so many hydras until your burn the wounds with end tags. But! there's a way around this: consider '<div><b><b><b><b></div></b></b></b>X'; that's funny... why isn't the X bold? it turns out that only three identical (down to attributes) formatting tags are remembered. Use this to your advantage when nesting identical formatting tags inside themselves.
- since we're saving on slashes: <table> (while in a row, ie <tr><table>) closes the last table, and opens a new one. You might think: "I don't want to start another table so soon!" fear not! the browser will move anything you put in a table, above the start of the table, right up until you start putting cells in it. This also avoids having to open the table later, you can start <tr>ing right away.
- you saved characters by dropping the doctype... but was it worth it? only with a valid doctype declaration will you <p> tags be closed automatically when you open tables. Just 4 closing </p> tags will make you wish you included that doctype. still think it's worth it?
- johncmouser 6y agowait, for which tags does this apply? because won't <p>one<p>two<p>three<p>four create four <p> elements nested together? does this only work with <a> tags? your third point about the triple-identical (reminds me about TCP ACK and Re-transmit haha) is pretty nuts though
- dragonwriter 6y ago> won't “<p>one<p>two<p>three<p>four” create four <p> elements nested together? No, because “A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.” https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission https://html.spec.whatwg.org/multipage/syntax.html#syntax-ta...
- johncmouser 6y agowow, two things: 1. thanks for the link. that documentation is realllly put together well. 2. for anyone else who goes to the docs, scroll down to the table bit. Official HTML never looked so close to markdown before. But I guess it's legal, with the <td> omissions, etc. cool stuff! EDIT: posting code here <table> <caption>37547 TEE Electric Powered Rail Car Train Functions (Abbreviated) <colgroup><col><col><col> <thead> <tr> <th>Function <th>Control Unit <th>Central Station <tbody> <tr> <td>Headlights <td> <td>y <tr> <td>Interior Lights <td>x <td>y <tr> <td>Electric locomotive operating sounds <td> <td> <tr> <td>Engineer's cab lighting <td>x <td>z <tr> <td>Station Announcements - Swiss <td>x <td>y </table>