Different use of 'float' in javascript
For inline float style detection in the <body> elements only !
Example 1
[get] element.style.float
<p style="float: right">...</p>
get style
Result.....:
Example 2
[get] element.style.cssFloat
<p style="float: right">...</p>
get style
Result.....:
Setting inline float styles in the <body> elements
Example 3
[set] element.style.float
set style
Example 4
[set] element.style.cssFloat
set style
For external stylesheets, style blocks in the <>head> and inline-styles as well
Example 5
window.getComputedStyle(element).getPropertyValue("float")
floating right by stylesheet
get style
Result.....:
Example 6
window.getComputedStyle(element).getPropertyValue("cssFloat")
floating right by stylesheet
get style
Result.....:
Example 7
window.getComputedStyle(element).getPropertyValue("css-float")
floating right by stylesheet
get style
Result.....:
Remarks
- To check in the HTML inspector of the Developer Tool.
- At this moment the
style.float
and style.cssFloat
syntax do exactly the same in at least
Firefox, Chrome, Opera and IE-11 on a Windows-7 desktop.
- In order to get the computed value of a float, only the css-syntax of the property is permitted:
float
(and
not cssFloat
or css-float
).
- The keyword 'float' (floating point variable) was a reserved keyword in older javascript versions, but not more in the modern versions.
See for instance this answer
on stackoverflow.com. I guess it has to do with the distinction between 32-bit floating point numbers
(Float32Array) and 64-bit floating point numbers
(Float64Array).
Francky Kleyneman, 10 jan. 2019