To render a webpage, the browser engine takes the HTML code and processes it step by step. Here's a breakdown of the process:
-
Parsing the HTML: The browser engine reads the HTML code and breaks it down into smaller, manageable parts.
-
Constructing the Document Object Model (DOM): The browser engine creates a tree-like structure, known as the DOM, which represents the HTML elements and their relationships.
-
Rendering the Layout: The browser engine uses the CSS (Cascading Style Sheets) to style the HTML elements according to their specified styles. The rendered layout is then displayed on the screen.
-
Executing JavaScript: If there is any JavaScript code in the HTML, the browser engine executes it to make the webpage interactive.
In your doubt, you mentioned "order to render a webpage, import entire browser engine". This is not accurate. The browser engine is a part of the browser, and it's not something you can import. Instead, you create a webpage using HTML, CSS, and JavaScript, and the browser engine renders it for you when you open the webpage in a browser.
References