Ways to conceal text that is not wrapped in an HTML tag

<div class="padd10_m">
<a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a>
<img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">                
</div>

I'm currently working on modifying the code above, specifically aiming to hide the "US" word. While I have successfully hidden the image that appears after "US," I am struggling to find a way to hide the actual text "US." If anyone knows the appropriate code to achieve this, please let me know!

Answer №1

Is this what you're looking for?

.padd10_m {
  font-size: 0px;
}
.padd10_m > * {
  font-size: 14px;
  /* Revert to normal font */
}
<div class="padd10_m">
  <a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> US
  <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">
</div>

View the working fiddle here

Alternatively

If you prefer using JavaScript (although it may not be necessary), consider the following solution:

var pad = document.querySelector('.padd10_m');
Array.prototype.forEach.call(pad.childNodes, function(el) {
  if (el.nodeType === 3) {   // check if it is a text node
    pad.removeChild(el);     // remove the text node
  }
});
<div class="padd10_m">
  <a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> US
  <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">
</div>

Answer №2

Here is a CSS solution:

.padd10_m { font-size: 0; }
.padd10_m * { font-size: 1rem;}

Answer №3

Experimenting with hiding elements using font-size

.content_hidden{font-size:0;}
.content_hidden > p{font-size:16px;}
<div class="content_hidden">
  <p>This text will be hidden</p>
  <img src="example.jpg">
</div>

Answer №4

Styling with CSS

   .padding-10 {
    font-size:0px;
    }

    .padding-10 a{
    font-size:14px;
    }

Creating HTML Content

<div class="padding-10">
<a href="http://www.website.com/page/" class="link" target="_blank">Click Here</a> 
US <img src="images/us-flag.png">                
</div>

Answer №5

By using :after, it is possible to insert a space between the word "admin" and the flag.

.addSpace{
  font-size: 0px;
}

.addSpace a{
  font-size: 16px;
}

.addSpace a:after{
  content: ' ';
}

Answer №6

<script type="text/javascript">
    document.body.innerHTML = document.body.innerHTML.replace(/UK <img/g, '<img');
</script>

Wow

Answer №7

If you want to position the image (US-Flag) over the text, you can use the following CSS:

.padd10_m img {
    margin: 0 0 -7px -25px;
    border: 5px solid #fff;
}

Another option is to make the font color the same as the background color.

img {
    margin: 0 0 -7px -25px;
    border: 5px solid #fff;
  }
<div class="padd10_m">
<a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> 
US <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">                
</div>

Update: If you also need to hide the image, you can try this CSS solution:

.padd10_m {
  width: 40px;
  overflow: hidden;
  white-space: nowrap;
}
<div class="padd10_m">
<a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> 
US <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.png">                
</div>

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

My array contains a list, and I need to determine how to ensure that a specific element is displayed first based on a condition in the mapping

Here is the object. let newObj = { firstValue:"abc", content:[ { "value": "123", "checked": true }, { "value": "456", "checked": false }, { "value": "789", "checked": tr ...

How can I center a <a> vertically within a list that has varying heights?

Help Needed: Alignment Issue with Anchor Tags in List I am facing a challenge with vertically aligning the anchor tags inside my list. The number of list items varies based on the pages of my website, so I have used display flex on the list and flex: 1 on ...

Solving relative paths in NodeJS/Express

My website is calling several scripts, images, styles, etc., from different folders both inside and outside the main folder: File Tree - / - website - scripts - data.js - customJquery.js - styles ...

Get the PDF in a mobile app using HTML5 and Javascript

For my HTML5/JavaScript-based mobile application, I am in need of implementing a feature that enables users to download a PDF file. The PDF file will be provided to me as a Base64 encoded byte stream. How can I allow users to initiate the download proces ...

Incorporate a corner box feature to bring attention to the typed.js functionality

I have successfully integrated typed.js into my project and now I am looking to replicate the highlighted text with an excel-like box in one corner. I've managed to get the text typing out while also adding an SVG for the box in HTML, but I'm hav ...

issue encountered when implementing slick.js in angular 6

Trying to implement slick.js, a carousel framework, in an Angular project. Initially attempted 'npm install slick --save' and manually adding the downloaded files to scripts and styles JSON objects. When that failed, resorted to importing the C ...

The browser window's location is redirected to an empty page

I'm currently working on a website that has a similar layout to this (). https://i.sstatic.net/c7I2y.png My main issue is with the code I've written to detect a click on the linkedin div and redirect accordingly. <script src="https://ajax.g ...

Identify and emphasize fields that contain identical, non-empty values

I am attempting to compare the values of textboxes and highlight them if they are the same, excluding any textboxes that are empty. Feel free to view an example on this JSFiddle link: http://jsfiddle.net/qjqa1et2/61/ Below is the jQuery code I am current ...

Are there more efficient methods than having to include require('mongoose') in each models file?

Is it possible to only require mongoose once in the main app.js file and then pass it to other files without loading it again? Will the script do extra work every time the same module is required? var mongoose = require('mongoose'); I'm wo ...

What is the best way to create a function that can disable console.log and be imported into other React files for easy access?

Here is the content of my static.js file: var Helper = { console.log: function(){ }, Login: function(){ var name; var password; //rest of the code } } module.exports = Helper; Now, in my test.js file: var Helper ...

Storing a dataURL in MongoDB for easy access through a local URL using JavaScript

Unclear title, Meteor App tool needed to upload file into MongoDB export const Files = new Mongo.Collection('files'); Creating addFile function : export const addFile = (nameArg: String, dataURL: String) => { Files.insert({ _id: uuid(), ...

Remain concealed once the lights dim

Looking for a way to fade out a logo in a preloader div after a call, but having issues with it becoming visible again once fully faded out. Ideally, I would like to keep it faded out or set it to display none using only CSS, although I can use jQuery if n ...

Middleware in Expressjs ensures that variables are constantly updated

I'm attempting to accomplish a straightforward task that should be clear in the code below: module.exports = function(req, res, next) { var dop = require('../../config/config').DefaultOptions; console.log(require('../../config/ ...

The animation of the splash screen in Angular is quite jarring and lacks fluidity

I am experiencing some issues with my angular splash screen animation. It works perfectly when there is no activity in the background, but when I simulate a real-life application scenario, the animation becomes stuttered, choppy, or sometimes does not anim ...

Is it necessary to confirm the validity of url.format(urlObject)?

I have been exploring the NodeJS URL API and am particularly interested in the url.format(urlObject) method. My goal is to develop a function that first validates the urlObject before using the format function, and throws a TypeError if any of the key/valu ...

Why is the click event not working in IE8 for JavaScript / jQuery?

There seems to be an issue with the program not functioning properly in IE8 for some users. The website in question is an English course where certain individuals are experiencing difficulty clicking on the correct answers. To view a demonstration of this ...

There is currently no loader set up for ".html" files within the Vitejs configuration, specifically for the index.html file

Hello, I have encountered a problem. I am working with Visual Studio 2022 and have created two projects within one solution - one for the back-end (ASP.NET) and the other for the front-end (Vue.js and Vite). The issue arises when I use the npm create vue@3 ...

Utilizing JSON data retrieved from an API to populate a dropdown menu in HTML

When making a request to an API, I encountered the following error: https://i.sstatic.net/v6PVt.jpg Can anyone advise me on how to insert this into an html select field using jquery ajax? I want it to look something like this: <select> <o ...

The alignment of navbar elements appears to be off in Jquery mobile

Currently working on an app using Jquery mobile, and encountering an issue where the navbar is not displaying elements in line. The google chrome console is indicating spaces between list elements. Upon removing these &nbsp characters, the elements ali ...

A WordPress website featuring the impressive capabilities of the Three.js JavaScript 3D library

I attempted to integrate the Three.js JavaScript 3D library into my WordPress website by including three.min.js in various parts: Within the body of a post <script src="/three.min.js"></script> In the footer <script type='text/ ...