Search code examples
csswebmobilemedia-queriesportfolio

Can I make a seperate HTML file for devices like mobile and tabs for my website?


I have made and published my website. I want to make it compatible with mobiles without using media queries as for that I have to change the whole code. Is it possible to have separate HTML files for mobiles? If yes, how to link that to desktop version?


Solution

  • It is possible if you filter it server side looking at user agent. But i cant say ive ever seen it done and it sounds like bad practice. A general rule of programming would be to avoid duplicating code. Or dont repeat yourself as the principle is called.

    If your mobile code is simple too different from the desktop code that you cant use media queries i would sugest just putting two sections on the page and using said media queries to show one and not the other.