Table of Contents

What are React HTML elements? (Built-In)

About

In React, HTML elements are:

Example

with Jsx

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 Pure Javascript

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
)

Syntax

They start with a lowercase letter whereas the component (React Element created by yourself or a library) starts with an uppercase letter.

Ref

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.