In React, HTML elements are:
In Jsx
.blue { color: blue; }
const ourP = <p className="blue" style={{textAlign: 'center'}}>Hello World</p>;
<div id="root"></div>
ReactDOM.render(
ourP,
document.getElementById('root')
);
With createElement, the same example as above.
const ourP = React.createElement(
'p' , // the type: the string equivalent of the HTML tag (ie h1, div, ...)
{
className: "blue",
style: {textAlign: 'center'}
}, // props are the equivalent of HTML attributes
['Hello World'] // children are other react element or a string for a text node
)
They start with a lowercase letter whereas the component (React Element created by yourself or a library) starts with an uppercase letter.
They are the only ones to be able to receive a ref directly to get the underlying DOM element. For component, you need to use React.forwardRef to make them ref aware.