Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How to link the HTML and CSS page if it is different for the desktop and mobile version?

For one of my pages I designed two pages one for the desktop and one for the mobile version. What is the best way to link the HTML and CSS file when having two different pages?

1 Answer

Maybe there is a way with javaScript but I cannot say for sure as i don't know how. How i build responsive sites is with media queries so look into those and it helps to not repeat your code. So look into media queries. An example would be

@media (max-width: 720px) { body { background: black; } }" The code above would change the background color to black when the browser is set between 0px and 720px. Or you can use min-width instead and when it hits 720px it will change to black. So 720px and above. You can use any CSS code inside media queries.

Hope this helps!