All You Need to Know About Making Responsive Websites Using Media Queries

  • 22nd Sep'21
  • 73
  • 5
  • 0

Website development has become a key to make your business reach our audience. You have to make your website catchy so that more people spend time on it. This is possible only when your website is responsive. 

Do you have to be dependent on a developer to make a responsive website? Well, not necessarily. Using media queries, hands down is the best way to ensure that your website appears the way you want it to be. 

Does it sound too simple? 

Let us understand how we can do it. 

 

What are responsive website designs?

A responsive design uses HTML/CSS to create a website design that adapts to various screen sizes. This can be achieved by: 

  • Using rem and em units instead of pixels 
  • Setting viewport/scale of each page 
  • Using Media Queries. 

Though the first two seem technical, the most used feature these days is media queries. 

 

What are Media Queries?

Media query is a feature of CSS which is released in the CSS3 version. The introduction of this feature made resizing the screen in different devices much easier. The feature enables the user to adjust the display of the webpage based on the device - i.e., it auto-adjusts its device/ screen height, width, and orientation. 

This feature provides a framework for creating code once and then using it many times. 

 

 

How to use Media Queries? 

There are many things you need to take into consideration when using media queries. Though it seems easy, certain things should be minutely observed, like structure, placement of images and text, range, and linking. 

 

How does media query look like when used in CSS/HTML 

 

The General Structure of Media Query includes: 

  • The @media keyword 
  • The not/only keyword
  • A Media type - either a screen, print, or speech 
  • Keyword ‘and’
  • Unique expression enclosed in parentheses 
  • CS code in open and close curly brackets 

 

Placement of Media Queries 

Media Query is a CSS property; therefore, it must be used in its proper styling language. There are different ways in which you can use Media Query, of which two that are widely used are - internal or external.

 

Internal Method

This includes adding  style tag to the head tag of the HTML file and create the media query within the parameters of the style tag. 

 

External Method 

This involves creating a media query in an external CSS file and link it to HTML via the link tag. 

 

Link Media Queries 

If you do not want to embed media queries in your code, you can use an alternative method. This is an external method through which you can insert it by adding a link tag. 

 

Conclusion 

These are various ways to make your website responsive by using Media queries and make it easier for your audience to use it. 

 

We, at OpenGrowth, are committed to keeping you updated with the best content on the latest trendy topics from any major field. Also, both your feedback and suggestions are valuable to us. So, do share them in the comment section below.

Sources/References:

*Note: The content published above was made in collaboration with our members.

About the author:

Prachi Chouksey (Editor), Super admin

An artist by heart and a writer by profession, Prachi is a vivacious reader.  She believes in hard work and her dedication has never let her down. She puts her heart and soul in everthing she does. Though life has not been a bed of roses for her, she affirms that the best way to live it is to maintain an equillibrium between the tunes of life.  


Post Your Comment

You may also like