• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » CSS Unit Guide (px, em, rem, vh, vw etc)

By Abhishek Ghosh October 8, 2022 8:19 pm Updated on October 8, 2022

CSS Unit Guide (px, em, rem, vh, vw etc)

Advertisement

If you’re a web developer or designing your WordPress theme, then it’s important to have a good understanding of the different available CSS units. These units allow you to control the size and spacing of elements on a webpage. In this guide, we will explore the different CSS units and how they work. We will also discuss when and where to use each one. By the end of this guide, you should have a better understanding of how to use CSS units to create responsive and effective web pages.

 

Absolute Length Units in CSS

 

Absolute means physical.

There are a few different units of measurement that you can use in CSS, but the most common is pixel (px). Each of the physical units has its advantages and disadvantages, so it’s important to understand the difference between them before choosing which one to use.

Advertisement

---

Pixels are the most commonly used unit of measurement in CSS. They’re easy to understand and work well in most situations. The only downside is that they’re not always accurate, especially when it comes to responsive design. 96px is/was one inch. That is because, when the unit standard was formulated, computer monitors had a resolution of 1024 x 768, and a DPI of 96. Today, 96px is less than one inch because of the huge number of pixels. Points (pt) is another unit like pixels, pt is 1/72th of an inch. Inch, and cm are also absolute units in CSS. But they have several understandable problems due to changing smartphone dimensions.

Pixel is still commonly used in web designing since we have a rough idea of how big 700px is. The sidebars and ad units can easily be expressed in pixels than in other units. We use these units in this way:

Vim
1
2
3
4
5
6
7
8
9
10
11
<style>
        .outer {
            background: white;
            border: 1in solid red;
        }
        .inner {
            background: blue;
            border: 1px solid black;
            margin: 10px;
        }
</style>

The above CSS will give a fixed-size box:

Vim
1
2
3
    <div class="outer">
        <div class="inner">EXAMPLE</div>
    </div>

CSS Unit Guide

 

Relative Length Units in CSS

 

Several different relative length units can be used to specify lengths in CSS. The most common relative length units are em, rem, %, vh, and vw.

The em unit is based on the font size of the element. Ems are similar to pixels, but they’re relative to the font size of the element they’re applied to. This can be helpful if you want your elements to resize based on the user’s font size preference. However, it can also be tricky to control how ems to scale, so they’re not always the best choice. If the font size is not specified, it will be inherited from the parent element.

The rem unit is similar to the em unit, but it is based on the root element’s font size. This means that if the root element’s font size changes, all elements using rem will change their sizes accordingly.

The vh and vw units are based on the viewport size. The vh unit is equal to 1% of the viewport height, and the vw unit is equal to 1% of the viewport width. These units are useful for making elements that resize automatically when the viewport size changes.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to CSS Unit Guide (px, em, rem, vh, vw etc)

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Steps To Install Nginx Plus on Ubuntu Server (HP Cloud)

    Here Are the Steps To Install Nginx Plus on Ubuntu Server Running on HP Cloud. Nginx Plus is the Paid Version of Nginx with Extra Features.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
  • Comparison of Tube Amplifiers and SemiconductorsSeptember 26, 2023
  • What is a Digital-to-Analog Converter (DAC)September 25, 2023
  • Tips on S Pen Air ActionsSeptember 24, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy