Skip to main content
February 4, 2015
Mobile

Introducing the Selection API specification

Developers who build rich text editing experiences (such as email, blogs, wikis, etc.) are familiar with challenges supporting a diversity of browsers. Today’s browsers support different functions and have a range of bugs to work around. There is an effort to improve this situation at the W3C, where we are working on the future of web editing. Selection is fundamental to editing so we are prioritizing investments in more interoperable selection, paving the way for a better experience across the web.

To this end, we’ve been working with browsers and developers at the W3C to specify a Selection API, allowing developers to interact with the user’s selection consistently and predictably. With help from developers and other browser vendors, the document recently reached First Public Working Draft – the first step towards becoming a W3C Recommendation. This is a work-in-progress publication which we’ll continue to evolve with the community via the W3C public process. It will allow developers to have a simpler, more powerful and interoperable way to design the selection experience of their site.

As we’ve evolved this proposal, we helped ensure that it covered several currently used APIs so that it can be a reference for browsers and developers to use when building and using these APIs. In the latest preview builds of IE on Windows 10, several new APIs from the W3C spec are now available. These include containsNode(), extend(), setBaseAndExtent(), and collapse(). The definition for each of these methods can be found in the spec. We chose to add these APIs in IE because they are used across the web today, as well as being requested in feedback from developers on Connect. We’ve also received feedback requesting the modify() API and we are discussing how to specify it at the W3C. We hope to provide it in IE and Project Spartan in a future release.

If you work with selection experiences on your site, try these out in the Windows 10 Technical Preview and let us know via Twitter or Connect how we can continue to improve this area and make your life easier!

– Ben Peters, Program Manager, Internet Explorer