Should I use% or 'px' in HTML

Regardless of whether it is HTML, XHTML or HTML5, you find that these annoying percentages clog all over the place. Nevertheless ... I see that a huge number of websites do not dare to approach them. Nevertheless, I was always encouraged to use them through uni.

So what should I use? What would lead to a better website design and why?

I know to avoid using height, although HTML5 really doesn’t like me not to determine height if I want to use percentages.

Thanks for taking the time to read.

+4
source share
2 answers

It really depends on what you want to create.
Sometimes I need to create a website that can be read by people with disabilities. If, for example, older people visit your site, it is useful to use% so that they can enlarge your page, and the layout still looks pretty.

Fixed design layouts Fixed Design layouts have a specific width and do not scale to fit the browser window. Web sites that use it can align to the left, center, or even align to the right, as if necessary.

Advantages of fixed layouts: With fixed design layouts, you have control over the line length, flow and placement of elements on the web page. The designer has a fixed space for work and the length of the text line and image placement can be easily marked.

Disadvantages of fixed layouts: Fixed design layouts tend to leave a lot of empty space on either side of the design when viewed on a high resolution screen. This dwarfs the size of the web page and gives the impression that it is floating on the screen.

Fluid Layout Fluid design layouts use percentages instead of pixels to determine their width and fill the entire browser window. They are also called fixed or dynamic projects.

Benefits of fluid layouts: One of the main advantages of fluid design layouts is their accessibility features. They serve a larger number of users. This is due to the fact that regardless of the resolution of the screen or the user's device, the corrected design layouts are better adapted. It uses the entire browser window, spreading. This maximizes the area for the displayed content and additional information can be seen on one go. Therefore, there is no empty space on the window screen. This is better than fixed layouts that leave a lot of empty space.

+4
source

For fonts, you should use percentages (either em, or rems) if you do not want to correct the font size in Internet Explorer. If you use pixels, Internet Explorer users who change their default font size in their browser settings will not see that the fonts increase / decrease. Thus, your text becomes less readable to users in this browser.

A huge resource for this is the first chapter of Dan Cederholm Bulletproof Web Design .

For layout using percentages or em, your design will be more flexible for resizing fonts / localization, etc. This is also described in the book.

+2
source

Source: https://habr.com/ru/post/1397393/


All Articles