r/HTML • • Oct 11 '26

Question Difference in screen size

Hello. I've created a website using HTML, CSS, and JavaScript for the first time. My problem is this: I wrote the code on a computer and adjusted the sizes to fit the large screen. Now, on my laptop, which has a smaller screen, everything is misaligned. Can you tell me how to fix this problem?

Thank you very much

3 Upvotes

34 comments sorted by

11

u/rackodo Oct 11 '26

Since everyone else in the replies are acting like children:

Look into responsive CSS! You can use media queries to set different rules based on the max width of the user's screen. Use this as a starting guide, and experiment from there.

1

u/aunderroad Oct 11 '26

Can you share a url or codepen?
It is hard to debug/provide feedback without seeing all of your code live in a browser.

Thank you!

1

u/Eulevonathen Oct 11 '26

I would but unfortunately it is a school project with personal information on it :(

6

u/aunderroad Oct 11 '26

Just copy and paste the code to codepen and omit the personal information. :)

2

u/gastapo67 Oct 11 '26

If you open the website in DevTools on Chrome on the computer you wrote the website on, you can adjust the screen size to any layout to see how the website will look at that resolution. Then it’s applying the responsive web design to accommodate the adjusted resolutions

1

u/Reasonable-Pay-8771 Oct 16 '26

One approach to consider *before* resorting to media queries and laying out multiple formats is: remove all your hardcoded sizes and: use fractions of the screen size for big things and use normalized units or relative increases/decreases for small sizes and: use as much semantic html as you can instead of divs which carry no intrinsic meaning.

Does that make sense? If you don't start by building it to a particular size but arrange everything in a proper hierarchy (maybe with flexboxes and such) then it will be more responsive without hardcoding even more particular sizes for different phone dimensions etc.

1

u/notepad987 Oct 12 '26

Examples at link:

Responsive Web Design Using Media Queries
https://www.geeksforgeeks.org/html/responsive-web-design-using-media-queries/

Layout Flexbox test - link to a GRID version too:
https://codepen.io/davidhelp/pen/ByQyPWr?editors=1100

-2

u/RealNamek Oct 12 '26

if largeScreenSize: showLargeSite()

if smallScreenSize: showSmallSite()

-6

u/Friendly_Antelope807 Oct 11 '26

Google shit

3

u/Eulevonathen Oct 11 '26

I like human interaction

-6

u/Friendly_Antelope807 Oct 11 '26

Take my salty nuts than

5

u/hooli-ceo Oct 11 '26

Username in fact does NOT check out

-2

u/Friendly_Antelope807 Oct 11 '26

Yeah CEO, idc

1

u/hooli-ceo Oct 12 '26

The bear is sticky with honey

-9

u/Friendly_Antelope807 Oct 11 '26

ASK Ai

10

u/Apprehensive_Sea5304 Oct 11 '26

This is not how people learn things

-2

u/[deleted] Oct 11 '26

[removed] — view removed comment

3

u/Apprehensive_Sea5304 Oct 11 '26

Try googling grammar

5

u/-svde- Oct 11 '26

don't be an asshole. if this is all you have to say, don't bother replying to the post. beginner devs have relied on senior/experienced devs since the communal internet was a thing.

0

u/Soft_Awareness_5061 Oct 11 '26

Ask AI is actually a better answer and will get him the solution faster than the guy that linked the wiki page for responsive design. Everyone being pissy because they can't gatekeep web design anymore.

2

u/-svde- Oct 11 '26

OP asked here for a reason, and specifically reiterated "I like human interaction".

it's not gatekeeping to tell other people to not be rude & dismissive to newbies. i enjoy helping people, and the person asking wants a real response. this is the opposite of gatekeeping. braindead take lol.

-4

u/Friendly_Antelope807 Oct 11 '26

"Devs" 🤣🤣🤣

6

u/-svde- Oct 11 '26

i've been a dev for over 2 decades. this is a programming/dev sub. if you don't like helping people and/or have no interest in html, there are plenty of subs to waste your time in. go find one.

2

u/TehFlip Oct 11 '26

Trolls are like wild animals. The more you feed them, the more they want more.
Your replies are all good, but it’s like giving peanuts to a squirrel. The squirrel won’t stop because it’s full. It’ll just start burying the nuts in the yard until eventually you run out of peanuts. Then they’ll be scratching at the door.
I feel like I went into too much detail with my analogy and you would have got it if I just said “please don’t feed the trolls.” Oh well, thanks for coming to my TED talk

0

u/Soft_Awareness_5061 Oct 11 '26

Ironically, you've been a dev for 2 decades and the guy that said Ask AI has been more help to OP than you have. I don't see your comment actually helping him. Well? We're waiting.