How can I prevent browsers from hiding content in specific viewports when I only want to target certain viewport sizes for hiding?

I'm having trouble with the HTML codes for "main" in relation to media queries. I want the content to only show on viewports smaller than 480px, but it's not working as expected. The browser seems to hide the content on all viewport sizes.

Here's the CSS media query code:

@media only screen and (min-width: 481px) {

                                             main { display:none;}

                                          } 

Below are the HTML codes. The "paragraph" class is used for alignment and font styling. Note that the opening and closing <main> </main> tags are not displayed here, just their content.

`

<p class="paragraph">

    At Durango Jewelry and Gem Shop, we offer unique wire-wrapped pendants and gems inspired by natural geometries and the beauty of nature.

</p>


<p class="paragraph"> 

    The featured pendant includes:
    
        <ul class="paragraph">
        
            <li class="listing"> <span style="color:red;">"Smoky Quartz"</span> gemstones, also known as <span style="color:red;">"Soulmate Crystal"</span></li>
            <li class="listing"> Over 2 carats gemstone weight</li>
            <li class="listing"> High-quality silver alloy requiring minimal polishing</li>
            
        </ul>




</p>


<p class="paragraph">

    Visit our store today!

</p>

}

Answer №1

It is important to include the following code snippet in your <head> section:

<meta name="viewport" content="width=device-width, initial-scale=1">

Reasoning: Media queries will not function properly without the presence of this essential meta tag.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Learn the process of sending information to a MySQL table using a select tag in PHP

I am attempting to use a select tag to submit data to a MySQL table using PHP. I have been successful in inserting data using the text type with the following code: <td> <label class="control-label">Image Type </label> </td> &l ...

How to Use AJAX to Read a Text File in JavaScript

Having trouble with AJAX! I have successfully set up a marquee on my website, but now I want it to dynamically fetch the text from a text file. The goal is to read the text from the file (which contains only one line) and assign it to a global variable nam ...

Clicking two times changes the background

I am facing an issue with three boxes on my website. Each box is associated with a corresponding div. When I click on any box, the div displays and the background color turns red. However, when I click on the same box again, the div disappears but the back ...

"Create a unique visual layout with CSS using a four-grid

When utilizing four div grids and increasing the content size of table 2, it causes table 3 to align with table 4, creating a large gap between tables 1 and 3. Is there a way to adjust the responsive content sizing for tables 1, 3, 5... and 2, 4, 6... in o ...

Tips for combining text and variable outcomes in printing

I created a calculator that is functioning correctly and displaying results. However, I would like to include a text along with the results. For example: You spent "variable result" dollars in the transaction. Currently, the results are shown only after ...

Importing script files based on certain conditions

I am trying to dynamically import script tags based on a parameter set in the URL. Here is my current approach: function getURLValues(name) { var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location ...

What happens with the styling in this project when the CSS file is blank?

As a first-year CS student in university, I have been diving into the world of React.js. Currently, I am exploring a resume project and noticed that both app.js and index.js files are empty. I am curious to know how the styling is achieved in this project. ...

The symbols ♥ and ♦ in HTML are displaying as black on Android devices, despite being styled as red in the CSS

In the midst of my card game development using HTML, JS, and CSS on the Meteor platform. To represent the hearts suit, I utilize &hearts; and for diamonds, it's &diams;. The color scheme is crimson with color: #FF0000; in the CSS code. The fon ...

Here's a way to align big text in the center while aligning small text at the bottom

How can I position two text blocks on the same line in HTML, with one text block having a larger font size and vertically aligned in the middle, while the other text block sits lower to create a cohesive design? To better illustrate what I mean, I have cre ...

Ways to enlarge an image while hovering the mouse over it without disrupting the positions of other images (JQuery)

Is there a way to achieve a similar effect to Google Images, where the image pops and comes in front when we mouse over it without affecting the positions of other images? This should only happen when the cursor is still and not moving around randomly. I ...

Various image resolutions designed for extra small, small, medium, and large screens

My image has a relative width and currently the src points to a single, large file (approximately 1000px). The issue arises on small devices with Opera and IE where the browser scaling results in pixelated images. Conversely, using a smaller image leads to ...

Error message displayed on PHP web page

I'm working on a page that will display "no query string" if $_REQUEST is null, and if not, it will show a page with the content saying "query string". Additionally, it should output the line "The query string is: var_dump($_REQUEST)". I've writt ...

In search of assistance in delivering HTML form data to a public HTTP service

Seeking assistance with forwarding html form data to a public http service. Any guidance or tutorial recommendations would be greatly appreciated! Below is the structure of my form: <span class="text"> <input class="text" type="text" name="First ...

Using AJAX in HTML to retrieve data from PHP

I am facing an issue with my HTML code: <body> <div class="po-logo"> <img src="img/logos/lw.png" alt="logo watchbees"/> </div> <form> <div class="mui-textfield mui-textfield--float-label reg-window"> <input id="u ...

Troubleshooting problem with displaying HTML content on Internet Explorer 10

My website was developed using jquery with a dynamic coding style. It was functioning properly in IE10 while working from Visual Studio. However, after deploying it to the production server, the entire style seemed broken in IE10. In all other versions o ...

Issue with Bootstrap checkbox buttons not rendering properly

I'm attempting to utilize the checkbox button feature outlined on the bootstrap webpage here in the "checkbox" subsection. I copied and pasted the html code (displayed below) from that page into a jsfiddle, and checkboxes are unexpectedly appearing in ...

retrieve data from html to store as NSString

I have extracted an HTML string from a UIWebView using the following code: NSString *html = [webview stringByEvaluatingJavaScriptFromString: @"document.documentElement.innerHTML"]; The content of the NSString is as follows: <head> <meta name= ...

Incorporating an external HTML page's <title> tag into a different HTML page using jQuery

I am faced with a challenge involving two files: index.html and index2.html. Both of these files reside in the same directory on a local machine, without access to PHP or other server-side languages. My goal is to extract the <title>Page Title</ ...

Let's apply some CSS to the font style within the body

I've been incorporating a "footer.php" page into all other pages of my website. This footer showcases the site's name at the bottom of the screen and uses a custom font loaded with @font-face. Initially, I had something like this placed inside t ...

Creating a responsive background image inside a div using Twitter Bootstrap

Is there a way to make the #bg image responsive, resizable, and proportional in all browsers? Sample HTML code: <div class="container"> <div class="row"> <div class="col-md-2"></div> <div class="c ...