Recently I was reading and stumbled across . He shared a short code snippet that caught my eye. It included some JavaScript which accessed an input element from the DOM ( ) and read or changed some of its properties. What was exciting and surprising to me was the property . Twitter a tweet by Dan Abramov Document Object Model defaultValue I immediately opened to read more about this property of and stumbled upon a few more properties that I wasn't aware of, which lead me to write this quick article. MDN HTTMLInputElements So here we go! defaultValue This is Dan’s Tweet example — let’s have a quick look and assume you have some HTML and query an input element which has a attribute (attributes are defined in the HTML whereas properties belong to JavaScript objects) defined. value <input type="text" value="Hello world"> You can now grab this element and start tinkering around with it. const input = document.querySelector('input'); console.log(input.value); // 'Hello world'input.value = 'New value';console.log(input.value); // 'New value' console.log(input.defaultValue); // 'Hello world' As you see that the value defined in the attribute is initially reflected in the element property . That makes total sense to me. When you now change , you can still access the "initial value" using (for checkboxes is also available). Pretty cool! value value value defaultValue defaultChecked for is a follows: The MDN definition defaultValue [It] returns / sets the default value as initially specified in the HTML that created this object. If you like you can play around with the code in . a CodePen indeterminate The property is a fascinating one. Did you know that checkboxes can have an additional visual state other than checked and not checked? is a property (there is no attribute for it) that you can use to put this little dash into a checkbox that you may have seen every now and then. indeterminate indeterminate const input = document.querySelector('input');input.indeterminate = true; Setting to doesn't have any effect on the value of the checkbox, and the only reasonable use case I can think of are nested checkbox like . indeterminate true Chris Coyier describes on CSSTricks doesn't work only for checkboxes though. It also can be used for radio buttons and progress elements. Let's take a group of radio buttons in which no radio button is selected. When you're not preselecting one element in a group of radio buttons none of them is selected and also none of them is not selected – thus all of them are in state. indeterminate indeterminate What’s cool is, that you can also use the CSS pseudo class pseudo-class to selected elements which could come in handy to show particular UI components when no radio button in a group is selected yet. :indeterminate .msg { display: none;} input:indeterminate ~ .msg { display: block;} What is interesting about the property is that you can set it to or and this will affect the pseudo-class for checkboxes but not for radios. . indeterminate true false Dealing with radio buttons the actual selection state of a group is always right And only to mention it for the sake of completion will also match a selector including when they don't have a attribute defined. progress elements :indeterminate value for is a follows: The MDN definition indeterminate [It] indicates that a checkbox or radio buttons have no value and are in indeterminate state. Checkboxes change the appearance to resemble a third state. Does not affect the value of the checked attribute, and clicking the checkbox will set the value to false. If you like you can play around with the code in . a CodePen , and selectionStart selectionEnd selectionDirection These three properties can be used to figure out what a user selected and they are very straightforward to use. If the user selects text in an input field, you can use these to evaluate what was selected. const input = document.querySelector('input'); setInterval( _ => { console.log( input.selectionStart, input.selectionEnd, input.selectionDirection; ); // e.g. 2, 5, "forward"}, 1000); What I did to test this is that I defined an interval which logs the selection values every second. and return numbers describing the position of my selection but surprisingly returns when you select things with your mouse or trackpad but or when you select text using SHIFT and the arrow or control keys. selectionStart selectionEnd selectionDirection none forward backward If you like you can play around with the code in . a CodePen And that’s it. :) Quick (and short) conclusion MDN is a fantastical resource. Even after using elements for eight years now there are always new things to discover, and this is what I love about web development. Personally, I try to read random MDN articles regularly (I have a daily Slack-bot that reminds me to open ) because there are always things to discover and I can only highly recommend it! input bit.ly/randommdn Thanks for reading! ❤️ Originally published at www.stefanjudis.com .