html - What is lt;span gt; lt; span gt; element? - Stack Overflow The span tag just tells the browser to apply what ever style changes are included within the span and if there is no styling within the span then there would be no formatting applied to the enclosed text This is a bit different from the div tag which incorporates a paragraph break even if no styling options are included within a div So it is useful when you want to apply styles to elements
What is a span and when should I use one? - Stack Overflow What is a "span"? A span<T> is: A very lightweight abstraction of a contiguous sequence of values of type T somewhere in memory Basically a struct { T * ptr; std::size_t size; } with a bunch of convenience methods A non-owning type (i e a "reference-type" rather than a "value type"): It never allocates nor deallocates anything and does not keep smart pointers alive It was formerly known as
How to get the value of a spans text contents - Stack Overflow It assumes the contents of the span will only be text, but that might not always be case You should use textContent instead of innerHTML if you strictly want a string to be returned to you innerHTML has the side effect of also returning any node element (s) if there's other DOM elements in there textContent will guard against this possibility