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

CSS

Jack Cummins
Jack Cummins
17,417 Points

In CSS can you change the text for larger screen sizes using Media Querries?

I was just wondering because I'm making a website that would be a lot better with that feature. If you know how than please tell me.

Thanks so much in advance, Jack

19 Answers

pat barosy
pat barosy
6,759 Points

A couple ways to do this. I’d probably use JavaScript or jQuery. With CSS I’d try to use a classes for the different text you want to change, then at the specific screen width I’d use display:none to hide the text I want to change & display: block to show new text (can do this in reverse order for the smaller sizes too)

Jack Cummins
Jack Cummins
17,417 Points

I'm gonna try it with CSS. I don't know jQuery or JavaScript.

Thanks for the help! Jack

pat barosy
pat barosy
6,759 Points

Hi Jack, If you mean increasing font-size as the screen size gets larger... then yes, you absolutely can. You’ll have to see at what breakpoint or screen size you want to increase the text, then just code the font-size you want into that specifics media query.

Jack Cummins
Jack Cummins
17,417 Points

I meant changing the text. Not changing the size of the text. Is there any way to do that? If so, how?

pat barosy
pat barosy
6,759 Points

No worries,

Let me know how it works out. If display:block doesn’t work, use display:inline-block

Jack Cummins
Jack Cummins
17,417 Points

I did something a bit different, but it worked out well and without you I would not have had the idea!

Thanks so much!

pat barosy
pat barosy
6,759 Points

Glad to hear that it worked out!! Appreciate that

Jack Cummins
Jack Cummins
17,417 Points

It worked out really well.

Thanks So Much Pat! Jack

pat barosy
pat barosy
6,759 Points

I’ll admit that I’m a bit curious about knowing your solution. Maybe it can help some other students as well. I can still remember the days when I had NO idea what I was doing lol Glad that I could help

pat barosy
pat barosy
6,759 Points

Thanks for sharing. Link redirects to “page not found” . Tried it on my mobile device. Will try in desktop when I get home.

Jack Cummins
Jack Cummins
17,417 Points

I'm sorry, the URL must have changed. The Website looks like this. I hope the URL of the website didn't change. [The code](view-source:http://port-80-kk0ufrkcxw.treehouse-app.com) is here. I hope that URL didn't change.

Jack Cummins
Jack Cummins
17,417 Points

They both didn't work again! I guess I'll give you my code here.

HTML:

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="CSS/style.css">
    <link href="https://fonts.googleapis.com/css?family=Changa|Kanit|Martel|Martel+Sans" rel="stylesheet">
  </head>
  <body class="home">
    <nav>
      <ul id="nav">
        <li class="link not-showing chosen"><a href="Webpages/about.html">About</a></li>
        <li class="link not-showin  chosen"><a href="Webpages/about.html">About Me</a></li>
        <li class="link not-showing chosen"><a href="Webpages/coding.html">Coding </a></li>
        <li class="link not-showin  chosen"><a href="Webpages/coding.html">Coding Experience</a></li>
        <li class="link not-showing"><a href="Webpages/contact.html">Contact</a></li>
        <li class="link not-showin"><a href="Webpages/contact.html">Contact Information</a></li>
      </ul>
    </nav>
  </body>
</html>

CSS:

@media (min-width:800px){
  .not-showing{
    display:none;
  }
}

@media (max-width:800px){
  .not-showin{
    display:none;
  }
}

That's not all of my code, it's just the code that you need to see. Thanks for helping me with this! Jack

pat barosy
pat barosy
6,759 Points

Great job!! One question though. Any reason you didn’t use 801px for min-width breakpoint to prevent any overlap in the media queries? Again, great job!!

Jack Cummins
Jack Cummins
17,417 Points

Thanks for the advice! Also, that was not my full code. I only included the ocde that you needed to see. Thanks for giving me my idea!

Jack

pat barosy
pat barosy
6,759 Points

No problem. Keep up the good work!!

Jack Cummins
Jack Cummins
17,417 Points

Which coding language are you curently learning about?

pat barosy
pat barosy
6,759 Points

I’ve danced around a few for the last couple of years but never really used them for anything more than personal knowledge. Now I’m refreshing what I know (HTML, CSS, Bootstrap, JavaScript, jQuery) in hopes of going freelance & launching a startup. Wordpress, is probably next on my list. How about you?

pat barosy
pat barosy
6,759 Points

Nice!!! A fellow front end web dev. You’re definitely well on your way. Mobile is something I should start thinking about as well. Here’s to reaching our goals.

Jack Cummins
Jack Cummins
17,417 Points

Wow! I'm working on front-end Web Development, after I finish that I'll do Java. After that Python. And after that I'll do WordPress. Then I'll start learning ios and android. After that I'll put all of my learning into action.

Jack Cummins
Jack Cummins
17,417 Points

Okay, I'll try mobile. What does it do?

pat barosy
pat barosy
6,759 Points

No, I meant that I should start getting familiar with learning development for iOS and Android as well.

Jack Cummins
Jack Cummins
17,417 Points

Oh. I'm not going to be doing that for a while.

Happy Coding, Jack