Text - Web APIs | MDN

archived 25 Jan 2017 10:34:24 UTC
Your Search Results

    Text

    The Text interface represents the textual content of Element or Attr.  If an element has no markup within its content, it has a single child implementing Text that contains the element's text.  However, if the element contains markup, it is parsed into information items and Text nodes that form its children.
    New documents have a single Text node for each block of text. Over time, more Text nodes may be created as the document's content changes.  The Node.normalize() method merges adjacent Text objects back into a single node for each block of text.

    ConstructorEdit

    Text()
    Returns a Text node with the parameter as its textual content.

    PropertiesEdit

    Text.isElementContentWhitespace Read only
    Returns a Boolean flag indicating whether or not the text node contains only whitespace.
    Text.wholeText Read only
    Returns a DOMString containing the text of all Text nodes logically adjacent to this Node, concatenated in document order.
    Text.assignedSlot Read only
    Returns the HTMLSlotElement object associated with the element.

    MethodsEdit

    Text.replaceWholeText
    Replaces the text of the current node and all logically adjacent nodes with the specified text.
    Text.splitText
    Breaks the node into two nodes at a specified offset.

    SpecificationsEdit

    Specification Status Comment
    DOM
    The definition of 'Text' in that specification.
    LSLiving Standard Removed the isElementContentWhitespace property.
    Removed the replaceWholeText() method.
    Added the Text() constructor.
    Document Object Model (DOM) Level 3 Core Specification
    The definition of 'Text' in that specification.
    RECRecommendation Added the isElementContentWhitespace and wholeText properties.
    Added the replaceWholeText() method.
    Document Object Model (DOM) Level 2 Core Specification
    The definition of 'Text' in that specification.
    RECRecommendation No change from Document Object Model (DOM) Level 1 Specification.
    Document Object Model (DOM) Level 1 Specification
    The definition of 'Text' in that specification.
    RECRecommendation Initial definition.
    Shadow DOM
    The definition of 'assignedSlot' in that specification.
    WDWorking Draft Initial definition.

    Browser compatibilityEdit

    Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 1.0 [3] (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) [3] (Yes) [4]
    wholeText 1.0 (Yes) 3.5 (1.9.1) (Yes) (Yes) (Yes)
    isElementContentWhitespace No support (Yes) (Yes)
    Removed in 10 (10)
    No support No support No support
    replaceWholeText (Yes) [1] [2] (Yes) 3.5 (1.9.1)
    Removed in 10 (10)
    (Yes) (Yes) [1] [2] (Yes) [4]
    Text() constructor 28.0 (Yes) 24.0 (24.0) No support 15.0 No support
    Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support (Yes) [3] (Yes) 1.0 (1.0) (Yes) (Yes) [3] (Yes) [4]
    wholeText (Yes) (Yes) 1.0 (1.9.1) (Yes) (Yes) (Yes)
    isElementContentWhitespace No support (Yes) (Yes)
    Removed in 10.0 (10)
    No support No support No support
    replaceWholeText (Yes) [1] [2] (Yes) 1.0 (1.9.1)
    Removed in 10.0 (10)
    (Yes) (Yes) [1] [2] (Yes) [4]
    Text() constructor (Yes) (Yes) 24.0 (24.0) No support 15.0 No support
    [1] Chromium is currently considering dropping its support.
    [2] Before Chrome 30 and Opera 17, the argument wasn't mandatory, like required by the specification.
    [3] Before Chrome 30 and Opera 17, splitText() argument was not mandatory, as required by the specification and implemented by IE and Gecko-based browsers.
    [4] The argument is not mandatory, though required by the spec.

    See alsoEdit

    Document Tags and Contributors

    Tags: 
     Contributors to this page: mattwojo, jpmedley, teoli, maybe, MHasan, Sheppy, Jürgen Jeka, jswisher, Ruakh, Brettz9
     Last updated by: mattwojo,

    Thanks! Please check your inbox to confirm your subscription.

    If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.
    See also
    1. Document Object Model
    2. Text
    3. Constructor
      1. Text()
    4. Properties
      1. assignedSlot
      2. isElementContentWhitespace
      3. wholeText
    5. Methods
      1. replaceWholeText()
      2. splitText()
    6. Inheritance:
      1. CharacterData
      2. Node
      3. EventTarget
    7. Related pages for DOM
      1. Attr
      2. ByteString
      3. CDATASection
      4. CSSPrimitiveValue
      5. CSSValue
      6. CSSValueList
      7. CharacterData
      8. ChildNode
      9. Comment
      10. CustomEvent
      11. DOMConfiguration
      12. DOMError
      13. DOMErrorHandler
      14. DOMException
      15. DOMImplementation
      16. DOMImplementationList
      17. DOMImplementationRegistry
      18. DOMImplementationSource
      19. DOMLocator
      20. DOMObject
      21. DOMParser
      22. DOMPoint
      23. DOMRect
      24. DOMString
      25. DOMTimeStamp
      26. DOMTokenList
      27. DOMUserData
      28. Document
      29. DocumentFragment
      30. DocumentType
      31. Element
      32. ElementTraversal
      33. Entity
      34. EntityReference
      35. Event
      36. EventTarget
      37. HTMLCollection
      38. MutationObserver
      39. Node
      40. NodeFilter
      41. NodeIterator
      42. NodeList
      43. NonDocumentTypeChildNode
      44. ProcessingInstruction
      45. PromiseResolver
      46. Range
      47. TextDecoder
      48. TextEncoder
      49. TimeRanges
      50. TreeWalker
      51. TypeInfo
      52. USVString
      53. UserDataHandler
      54. XMLDocument
    0%
    10%
    20%
    30%
    40%
    50%
    60%
    70%
    80%
    90%
    100%