html - Stange PRE tag (or lack thereof) behavior -
given html
<pre> <div class="px_xml"><addfiledialogplaces id="<b>rvt_2016 places</b>" delete_prior="true"> <div class="px_ind"><place id="favorites">c:\users\[px~user]\links</place> <place id="datasets">c:\programdata\datasets</place> <div class="px_ind"><place id="families">c:\programdata\assets\revit\2016\libraries</place></div> <place id="desktop">desktop</place> <place id="my computer">::{20d04fe0-3aea-1069-a2d8-08002b30309d}</place> <place id="my network places">::{208d2c60-3aea-1069-a2d7-08002b30309d}</place> <place id="documents">personal</place> <delete>revit server network view</delete></div> </addfiledialogplaces></div> </pre>
and in custom css
.px_xml { font-family: monospace; font-size: .7em; color: #0000cc; margin-bottom:0; display: block; } .px_ind { margin-left: 2em; display: inline-block; }
everything works expected. however, if remove pre tags, seem extraneous since setting monospace font css, color override applies through second div.
now know keep pre , skip .px_ind styling, prefer not 2 reasons. one, forces me indents right hard way, , 2 leaves me no easy way revise amount of indent later. rather keep spaces in xml me understand while editing, while allowing styling drive final expression, requires no pre. , seems odd thing pre tag do, or lack of do, want understand it.
pre
meant hold phrasing content, div
not 1 of content allowed. browsers deal can syntaxe errors.
https://www.w3.org/tr/html5/grouping-content.html#the-pre-element
you may use browser interprets error if missimbricate div
, pre
, forgot close 1 or both them. .pix_ind
after .px_xml
, not inside it, css not inherited anymore.
what can remove pre
tag , use css white-space:pre;
instead.
.px_xml { white-space: pre; /* here pre tag no longer needed */ font-family: monospace; font-size: .7em; color: #0000cc; margin-bottom: 0; display: block; } .px_ind { margin-left: 2em; display: inline-block; }
<div class="px_xml"><addfiledialogplaces id="<b>rvt_2016 places</b>" delete_prior="true"> <div class="px_ind"><place id="favorites">c:\users\[px~user]\links</place> <place id="datasets">c:\programdata\datasets</place> <div class="px_ind"><place id="families">c:\programdata\assets\revit\2016\libraries</place></div> <place id="desktop">desktop</place> <place id="my computer">::{20d04fe0-3aea-1069-a2d8-08002b30309d}</place> <place id="my network places">::{208d2c60-3aea-1069-a2d7-08002b30309d}</place> <place id="documents">personal</place> <delete>revit server network view</delete></div> </addfiledialogplaces></div>
typical example show browser fixes somehow html: when build table, if tbody
missing, browser add , can used selector in style sheet.
tbody td { border: solid; padding:1em; }
<table> <tr> <td>is <code>tbody</code> missing ?</td> </tr> </table>
Comments
Post a Comment