Conceal a <div> element that includes a link using CSS within the @

Having trouble finding the right css selector to hide this div on mobile screens:

<div w3-include-left-html="borders/border-left.html"></div>

Tried various selectors with no success. For example:

<style>
@media screen and (max-width: 900px) {
div.borders/border-left.html {
display: none;
    }
}

The div code with URL is functioning properly, but the selector to conceal it on mobile devices remains elusive.

No luck finding a solution on StackOverflow for utilizing a css selector with div code containing a URL like the above example.

Any insights or suggestions would be greatly appreciated.

Thank you!

NOTE: Complete code including the div file is provided below. It's used for dynamically inserting menus via HTML files on our extensive website and is working well. Issue arises when trying to hide certain menus on smaller screens. Unable to find a solution on W3 or any other sources.

<!DOCTYPE html>
<html>
<script>
function includeHTML() {
  var z, i, elmnt, file, xhttp;
  /*loop through a collection of all HTML elements:*/
  z = document.getElementsByTagName("*");
  for (i = 0; i < z.length; i++) {
    elmnt = z[i];
    /*search for elements with a certain atrribute:*/
    file = elmnt.getAttribute("w3-include-left-html");
    if (file) {
      /*make an HTTP request using the attribute value as the file name:*/
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4) {
      if (this.status == 200) {elmnt.innerHTML = this.responseText;}
      if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
      /*remove the attribute, and call this function once more:*/
      elmnt.removeAttribute("w3-include-left-html");
      includeHTML();
    }
  }      
  xhttp.open("GET", file, true);
  xhttp.send();
  /*exit the function:*/
  return;
    }
  }
};
</script>

<body>

<div w3-include-left-html="borders/border-left.html"></div> 

<script>
includeHTML();
</script>
</body>
</html>

Answer №1

Attempting to apply the 'class' selector to div.borders, but the div in question lacks a class attribute

Consider using the following syntax instead:

div[w3-include-left-html='borders/border-left.html']

Answer №2

Here is an example of how you can hide a left border on screens less than 900px wide using CSS:

@media screen and (max-width: 900px) {
[w3-include-left-html="borders/border-left.html"] {
display: none;
    }
}

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

What is the method for retrieving the value from a text input using JavaScript?

let userInput = document.getElementById('myFieldId'); console.log(userInput.value); <!DOCTYPE html> <html> <head> </head> <body> <input type="text" id="myFieldId"/> <script src="main.js">< ...

Change the background color of a table cell based on its value with the help of JavaScript

I am attempting to apply color to cells in an HTML table (generated automatically by Python and Django) based on the content of the cells. Below is my table. I want to specifically color the column "status". Whenever the word "Cloture" appears, I would li ...

Choose and manipulate a set of elements using Jquery

Below is a piece of code I have: <div class="timeline"> <div class="timeslice" data-tid="360"></div> <div class="timeslice" data-tid="360"></div> <div class="timeslice" data-tid="360"></div> <di ...

Optimal approach for reutilizing Javascript functions

After creating a simple quiz question using jQuery, involving show/hide, addClass, and tracking attempts, I am now considering how to replicate the same code for multiple questions. Would it be best practice to modify all variables in both HTML and jQuery, ...

Manipulate the value of the <input> element when focused through JavaScript

After I focus on the input field, I was expecting to see Bond-Patterson, but instead, I am only getting Bond. What could be causing this discrepancy and how can it be fixed? $('input[name="surname"]').attr("onfocus", "this.placeholder='Bo ...

How to eliminate the unnecessary gap between rows in a Vue div displayed as a grid

I have recently started working with Vue and in my current project, I encountered a challenge where I needed to display 2 players in each row within a div. To achieve this, I utilized the display: grid; CSS property on the playerDiv id. However, I am facin ...

Implementing the CSS link tag in the header of a NextJS 13 application for enhanced styling

In my Next 13 application, I'm looking to link directly to a basic CSS file. Unfortunately, adding it to the Head component hasn't yielded any results for me. I've also attempted to create a custom _document within both the app and pages, bu ...

Tips for creating a custom notification container using CSS

I have been tasked with creating a notification display for a web application. The notifications should appear in the bottom right corner of the window and disappear after a certain period. Alternatively, users can click on a notification to dismiss it. Wh ...

Unable to establish proper functionality of username variables in Node.js chat application

For my latest project, I am developing a chat application in node.js following a tutorial from socket.io. The main objective of the app is to allow users to input their username along with a message, which will then be displayed as "username: message" in t ...

Using MySQL data in an EJS file to create a personalized Profile Page

In the midst of a personal project aimed at honing my web development skills and gaining a deeper understanding of the intricacies of the field, I have hit a roadblock. The focus of this project is to create a profile page, and while I have successfully co ...

Problem encountered in AngularJS CheckBox binding where the checkbox remains unchecked despite the model having a checked value

I am working with AngularJS and have implemented the following code: <div > <input type="checkbox" ng-model="vehicleDetails.selfOwned"> Owned </div> <div> {{vehicleDetails.selfOwned}} </div> The mo ...

Make Jekyll process HTML files even without front matter by using the Knitr tool to add front matter to the HTML files

I am currently utilizing RMarkdown in combination with knitr to produce various HTML documents. After uploading these documents to GitHub, Jekyll is utilized for rendering the files onto GitHub pages. My objective is straightforward: I want the index.html ...

How can we retrieve the value from a textBox using JavaScript in Selenium WebDriver?

https://i.sstatic.net/6ni0f.pngTrying to extract text from an input tag that is missing in the HTML code, leading to the need for JavaScript to retrieve the value. Unfortunately, running the code in Eclipse returns null as the result. The HTML and Seleni ...

Tips for maintaining the navigation tab's consistent appearance

Whenever I click a button on the sidebar and the current tab is the second tab, the navigation bar switches to display the first tab. How can I prevent this switch and keep the second tab displayed when clicking a button on the sidebar? The code for this ...

What is the best way to enlarge the image to a specific percentage?

Although I have never programmed in HTML or worked on web projects before, I am currently using a git repository where the project is client-server. This means I need to modify the code to suit my requirements, which includes working with HTML. My problem ...

Place a div box beneath another div box that is absolutely positioned, without requiring knowledge of its height

My website features an arrangement of pictures placed within div boxes and positioned absolutely to my liking. .char1 - .char5 are correctly positioned. Now, I am seeking a way to align .char6 - .char10 directly under .char1 - .char5. Is there a smart app ...

Customize the Emotion Styled Material UI Tab Indicator Overwrite

Looking for a way to customize the appearance of tab indicators using Emotion styled components. I'm struggling to target nested classes in my code. Here's what I have so far: const StyledTabs = styled(Tabs)( { classes: { indicator: ...

What is the best way to deactivate certain JavaScript functions on my webpage when accessed through a mobile device?

Is there a way to disable specific JavaScript functions when accessing my website from a mobile device? While I can achieve this using CSS only, certain buttons require JavaScript functionality. Below is the internal JavaScript code: var menuBtn = docume ...

What is the method for determining the gaps between cells in a grid-based puzzle game similar to Sudoku?

this is my current code and it's successfully functioning var cellSize:Number = 36; var cellGap:Number = 4; var row:Number; var col:Number; for (var a:int = 0 ; a < puzzleSTR.length ; a++) { col = a % 9; row = Math.floor(a / 9); ...

Is there a way for me to insert a variable into the src attribute of my img tag like this: `<img alt="Avatar" src=`https://graph.facebook.com/${snAvatarSnuid}/picture`>`

I need assistance with passing a variable called snAvatarSnuid within the img src tag, specifically after facebook.com/ and before /picture as shown below: <img alt="Avatar" src=`https://graph.facebook.com/${snAvatarSnuid}/picture`> Note: 1) The ht ...