r/WebdevTutorials • • Nov 15 '20

Frontend One line of code made my site mobile friendly!

I'm using a free bootstrap theme for the initial build of my site. I've had a couple thousand users over the last few days, and one of the top couple of pieces of feedback was makkng the site mobile-friendly.

Being new to the front-end, I apologised and said I'd try my best to improve it, but depending on the difficulty of solving the problem it might take a while.

After using Google's mobile friendly test, I found that my 'viewport' was not set.

I had no idea what this meant, googled it and 30 seconds later my site was mobile-friendly! 🥳

I was missing one line of meta code in the head of the html that told the browser to measure the device width.

Here's the code:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

I hope that helps someone speed up their mobile-readiness as I could have really done with this info a few days ago!

41 Upvotes

2 comments sorted by

1

u/[deleted] Nov 16 '20

Nice

1

u/Aayush9990 Nov 16 '20

This line actually automatically comes along with the boiler plate code in vscode