What is html page size

What is the standard width for a website in pixels?

Fast forward to today and responsive web design is becoming the standard. Your website should adapt to the many different screen sizes. At least: HD Screen, Desktop, Laptop, Tablet, and Mobile.

11 Answers 11

There is no standard, despite most developers assume 1024×768 as standard.

There is a CSS grid system named 960grid which assumes the body width as 960px, then breaks columns in 96 columns with 10px, or 80 with 12px.

The problem is: PC screens are getting bigger and bigger always, slowly in some regions but are.

In the other hand, at tech-tops, you have smaller screens in mobile devices and netbooks.

Dealing with this reallity can be painful. There is CSS Media Queries to the rescue. Alternatively, you can use tag link (with rel handheld) to provide an alternative version to mobile devices.

Follow some reference links for you

What is the standard width for a website in pixels?

Any number greater than 0 and less than infinity.

Current best practices for Responsive Web Design (RWD) are to support every device regardless of its width in pixels. Typically this involves using media queries to provide different styles for different ranges of screen sizes. The actual ranges used matter less than the design being consistent across sizes, and the site maintaining functionality across sizes.

Users are very likely to see different screen sizes without thinking much about it, so you want to minimize the amount of surprise when they drag a window to dock on half their screen, or happen to tilt their phone.

Some common width ranges used are:

These ranges are so common that I’d say they’re practically a standard. Not all ranges need to be used, for example a site might be fluid width for anything below 768 and then fixed width and centered for 768+.

With all that said, be aware that the numbers you use don’t particularly matter so long as the site is functional on whatever device a user chooses to view it on.

Now to the tricky part, the actual data. If you’re redesigning a site, the only data that matters is your own. What Wikipedia or Stack Overflow, or Google, or any-other-large-website-that-might-list-analytics-data says is irrelevant to your data for your site.

If your statistics show most users primarily using a particular range of device widths, you should probably focus on serving those users first. That all said, If your design is properly responsive you won’t need to focus on any particular size at all.

For new websites or sites that didn’t previously have analytics, heavily consider using a mobile-first approach, and be sure to use analytics so that you can properly adapt to your user base.

Old, Out-of-date Pre-RWD Version for Posterity’s Sake

I am surprised that no one else has thought to mention browser size by google.

80% of viewers can handle up to 1000px width, but the ones that can handle more than 1000px width often don’t. With wide screen monitors many people will align their windows to half the screen. Now that Win7 supports drag-n-dock, it’s likely it will become even more popular.

As for height: your first impression to the user is at the top of the page up to around ~600px. However, most users know and expect content to fall «below the fold» and are willing and able to scroll.

If you want to go wider than 1000px, I’d highly recommend a fluid layout so that users on netbooks and smaller screens can still see the content properly.

~960px tends to be a standardized width, but really it depends on the content and the style.

Источник

HTML vs Body: How to Set Width and Height for Full Page Size

Dave Gray

Dave Gray

HTML vs Body: How to Set Width and Height for Full Page Size

CSS is difficult but also forgiving. And this forgiveness allows us to haphazardly throw styles into our CSS.

Our page still loads. There is no «crash».

When it comes to page width and height, do you know what to set on the HTML element? How about the body element?

Do you just slap the styles into both elements and hope for the best?

If you do, you’re not alone.

The answers to those questions are not intuitive.

I’m 100% guilty of applying styles to both elements in the past without considering exactly which property should be applied to which element. 🤦‍♂️

It is not uncommon to see CSS properties applied to both the HTML and body elements like this:

Does It Matter?

The above style definition creates a problem:

Setting min-height to 100% on both elements does not allow the body element to fill the page like you might expect. If you check the computed style values in dev tools, the body element has a height of zero.

Meanwhile, the HTML element has a height equal to the visible part of the page in the browser.

Look at the following screenshot from Chrome Dev Tools:

empty_body

Why Does This Happen?

Using a percentage as a size value requires the element to reference a parent to base that percentage on.

The HTML element references the viewport which has a height value equal to the visible viewport height. However, we only set a min-height on the HTML element. NOT a height property value.

Therefore, the body element has no parent height value to reference when deciding what 100% is equal to.

And The Problem May Be Hidden

If you started out with enough content to fill the body of the page, you might not have noticed this issue.

And to make it more difficult to notice, if you set a background-color on both elements or even on just one of them, the viewport is full of that color. This gives the impression the body element is as tall as the viewport.

It’s not. It’s still at zero.

The image above is taken from a page with the following CSS:

Reverse-inheritance?

In a strange twist, the HTML element assumes the background-color of the body element if you don’t set a separate background-color on the html element.

So What is the Ideal Height Setting for a Full Responsive Page?

For years, the answer was the following:

This allows the HTML element to reference the parent viewport and have a height value equal to 100% of the viewport value.

With the HTML element receiving a height value, the min-height value assigned to the body element gives it an initial height that matches the HTML element.

This also allows the body to to grow taller if the content outgrows the visible page.

The only drawback is the HTML element does not grow beyond the height of the visible viewport. However, allowing the body element to outgrow the HTML element has been considered acceptable.

The Modern Solution is Simplified

This example uses vh (viewport height) units to allow the body to set a minimum height value based upon the full height of the viewport.

Like the previously discussed background-color, if we do not set a height value for the HTML element, it will assume the same value for height that is given to the body element.

Therefore, this solution avoids the HTML element overflow present in the previous solution and both elements grow with your content!

The use of vh units did cause some mobile browser issues in the past, but it appears that Chrome and Safari are consistent with viewport units now.

Page Height May Cause a Horizontal Scrollbar

Shouldn’t this say «Page Width»?

In another strange series of events, your page height may activate the horizontal scrollbar in your browser.

When your page content grows taller than the viewport height, the vertical scrollbar on the right is activated. This can cause your page to instantly have a horizontal scrollbar as well.

So What is the Fix?

You may sleep better knowing it starts with a page width setting.

This problem arises when any element — not just the HTML or body element — is set to 100vw (viewport width) units.

The viewport units do not account for the approximate 10 pixels that the vertical scrollbar takes up.

Therefore, when the vertical scrollbar activates you also get a horizontal scrollbar.

How to Set the Page for Full Width

Not setting a width on the HTML and body elements will default to the full size of the screen. If you do set a width value other than auto, consider utilizing a CSS reset first.

Remember, by default the body element has 8px of margin on all sides.

A CSS reset removes this. Otherwise, setting the width to 100% before removing the margins will cause the body element to overflow. Here’s the CSS reset I use:

How to Set Width to Your Preference

While it may not always be necessary to set a width, I usually do.

If you set the width to 100% on the body element you will have a full page width. This is essentially equivalent to not setting a width value and allowing the default.

If you want to use the body element as a smaller container and let the HTML element fill the page, you could set a max-width value on the body.

Conclusion

With no height value provided for the HTML element, setting the height and/or min-height of the body element to 100% results in no height (before you add content).

However, with no width value provided for the HTML element, setting the width of the body element to 100% results in full page width.

This can be counterintuitive and confusing.

For a responsive full page height, set the body element min-height to 100vh.

If you set a page width, choose 100% over 100vw to avoid surprise horizontal scrollbars.

I’ll leave you with a tutorial from my YouTube channel demonstrating the CSS height and width settings for an HTML page that is full screen size and grows with the content it contains:

Do you have a different way of setting the CSS width and height that you prefer?

Источник

Читайте также:  Rails javascript in view
Оцените статью