Hacker News new | ask | show | jobs
by zffr 272 days ago
One challenge is that JSON is for data and HTML is for UI. When a client gets JSON it can transform the data to make it ready for the UI. With HTML, the client is locked into the UI chosen by the server.

What if the client wants to render the output of an API in different ways depending on what screen is visible? If the server API outputs JSON, this is trivial. If it outputs HTML the client is stuck into rendering what the server gives it.

2 comments

That's why GP mentioned the Accept header, the client can choose at runtime which one it wants.
i don't do frontend so apologies if it's a dumb question.

if html is for ui, what is css for?

i always thought html was for documents/data (like xml light)

Html is for structure, css for appearance. OP's point still applies
thanks!