What is the shortest way to pretty print a org.w3c.dom.Document to stdout?

Call printDocument(doc, System.out), where that method looks like this: public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException { TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, “no”); transformer.setOutputProperty(OutputKeys.METHOD, “xml”); transformer.setOutputProperty(OutputKeys.INDENT, “yes”); transformer.setOutputProperty(OutputKeys.ENCODING, “UTF-8”); transformer.setOutputProperty(“{http://xml.apache.org/xslt}indent-amount”, “4”); transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out, “UTF-8”))); } (The indent-amount is optional, and might not work with your … Read more

Autocomplete off vs false?

You are right. Setting the autocomplete attribute to “off” does not disable Chrome autofill in more recent versions of Chrome. However, you can set autocomplete to anything besides “on” or “off” (“false”, “true”, “nofill”) and it will disable Chrome autofill. This behavior is probably because the autocomplete attribute expects either an “on” or “off” value … Read more

Which are the standard W3C meta tags?

HTML5 You can only use the following values in HTML5. If you need a value not listed, you’d have to register it first. name values Standard metadata names (defined in the HTML5 spec) MetaExtensions (registered in the WHATWG wiki according to the HTML5 spec) http-equiv values Pragma directives (defined in the HTML5 spec) PragmaExtensions (registered … Read more

jQuery serializeArray doesn’t include the submit button that was clicked

Is [there] another method that DOESN’T exclude the activated button in a serialization? There is not, the behavior is based on the submit event of the <form>, not of a button, e.g. hitting enter or calling .submit() in JavaScript. You’re mixing 2 concepts here, a .serialize() or .serializeArray() may or may not have anything to … Read more

Why are CSS named grid areas not in quotes?

The CSS Grid spec developers decided to use identifiers instead of strings, when defining named grid areas with the grid-area property, for the sake of consistency with the rest of CSS. The vast majority of CSS properties use identifiers, not strings, for their values. (Notable exceptions to this rule include font-family, content and grid-template-areas, which … Read more

What is the point of CSS collapsing margins?

The general meaning of “margin” isn’t to convey “move this over by 10px” but rather, “there must be 10px of empty space beside this element.” I’ve always found this is easiest to conceptualize with paragraphs. If you just gave paragraphs margin-top: 10px and had no margins on any other elements, a series of paragraphs would … Read more