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

Andrea Dinh
Andrea Dinh
4,946 Points

What are some of the advices for coding mobile to desktop version, if their pages' contents are different?

I am a beginner to web development, any advices/ recommended references if I have to code a website out of the mark-ups from this course? I notice there are quite big differencies in terms of contents between the mobile version and desktop/tablet one. The mobile version doesn't have any <p> element and headings are completely different. How can I adapt things in HTML to different versions?

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Andrea,

First of all, it doesn't matter what platform you're viewing a website in, it will always have the same HTML. So as you rightly suggest, you optimise your HTML for smaller devices first and then scale the content up. Doing this will give you the best chance of making good interfaces no matter what the size of the screen.

So how do you get content to appear on one screen size for not the other? Well each element has properties that can be manipulated using CSS. Each element for example, has a display and visibility property which are set to show up on the screen by default.

The way you manipulate them depending on screen size is with media query breakpoints.

Take this simple example

@media screen and (min-width: 480px) {

   p {
     display: block;
}

}

@media screen and (max-width: 479px) {

   p {
     display: none;
}

}

Let's say you have a simple HTML document with only one paragraph element in it. Let's also say for whatever reason, you wanted to remove that paragraph on screen below a width of 480pixels. The way to tell the browser to remove that paeagraph is by giving it a display property of none.

If you then tested the page on the browser and decreased the wifdth short enough the paragraph would disappear. I hope this helps clarify things go you :)

Andrea Dinh
Andrea Dinh
4,946 Points

Thanks a lot for a clear explaination, I've tried and it worked so far!

Bruno Navarrete
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 Points

Jonathan is right, in your front-end development journey you'll find several tools to make this easier but for now start try to read everything you can on CSS and media queries.

Once you think you got the hang of it, move on to Bootstrap which is an awesome front-end framework for mobie-first web apps and sites created by the guys at Twitter.

Andrea Dinh
Andrea Dinh
4,946 Points

Thanks for the suggestions!