How does html rendering works basically?

I have a html file which includes css and js files in it.
I put that on a server running and configured everything.
Now my Html can directly include css and js files through tags but I have to use ajax for accessing json and other files.
So the server first reads html and sends all included files with it to the client browser or the html first go to client browser where it complies and demands js and css from the server then.

The HTML document has the links to the CSS and JS files required. When the browser parses the HTML file for rendering, the server will have already sent the supporting files (including code from any refeenced CDN’s like bootstrap or jQuery).

The server doesn’t read HTML, to the server it’s just a file full of text, a blob of binary code. When a request to the server is made in the form of a URL, it is programmed to respond by sending the text file [or rather a stream of binary along with something that says “this is text/html”] associated with the URL (say index.html) back to the client that requested it (in this case, a browser).

The browser is a program whose primary job is to read these text files and use the data and the tag structure they contain to spit out a visual version. A browser reads the file from top to bottom, and when it finds a tag like <link href="mystyles.css" />, it is programmed to look at the href attribute, and make another request to get that text file (which it does before carrying on reading the .HTML file in many cases). That file informs how it displays the rest of the page. And so on. (Note that browsers are incredibly complex programs, moreso than any server)


As @DanCouper said, the browser is what reads your html. You don’t even need the server to run an html websites. You can open html files from your computer. Just open them with the browser instead of your text editor. As long as your paths are either configured to point to the files on your machine, or use a relative path name, the browser will even grab those files.

1 Like