See the following examples, save each code as html files(say example1.html and example2.html) and open in a browser you can see the result
- Simple example without using jsx
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/javascript">
ReactDOM.render(
React.createElement(
"main",
null,
React.createElement("h1", null, "Below is my component"),
React.createElement(Html_component, null)
),
document.getElementById("root")
);
function Html_component() {
return React.createElement(
"main",
null,
React.createElement("div", {
style: {
borderRadius: "50%",
backgroundColor: "black",
width: "10px",
height: "10px"
}
})
);
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- Don't use this in production: -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
ReactDOM.render(
<main>
<h1>Below is my component</h1>
<Html_component />
</main>,
document.getElementById("root")
);
function Html_component() {
return (
<main>
<div
style={{
borderRadius: "50%",
backgroundColor: "black",
width: "10px",
height: "10px"
}}
></div>
</main>
);
}
</script>
</body>
</html>
you can see more details about jsx here https://reactjs.org/docs/jsx-in-depth.html