Tips on creating CSS for an element with certain text within it?

I have a text element List that I need to select. Instead of using xpath like -

//li[text()='List']

I want to use css. How can I write css for this? I attempted the following after referring to but it didn't work.

li:contains('List')

Answer №1

It's important to note that the CSS feature :contains('some text') has been deprecated and is no longer recommended for use. Instead, consider using xpath instead as a more suitable alternative in your situation. Unfortunately, there is currently no way to achieve the desired outcome using CSS alone.

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

Displaying a Bootstrap button and an input box next to each other

Looking for advice on aligning or arranging a button and input box side by side in Bootstrap without grouping. I've searched online for examples, but they all involve grouping of elements. jsfiddle: https://jsfiddle.net/erama035/p9dagmL3/3/ <div ...

Looking for Angular 2 material components for dart with CSS styling? Need help centering a glyph on your page?

HTML: <div class="border"> <glyph class="center" [icon]="'star'" ></glyph> <div class="centerText"> This Is Text that is centered. </div> </div> Css: .centerText{ text-align: center ...

Removing the dividing line between columns in an Antd table: A simple step-by-step guide

Do you notice the lines dividing each table column heading in the image? I want to get rid of these lines from the table. The table component I am using is Antd table. https://ant.design/components/table#examples https://i.stack.imgur.com/Npx5G.png ...

Creating a p5.js circle on top of an HTML image: A step-by-step guide

Currently, I am integrating an image into my web application using standard JavaScript and HTML. The image represents a basic map, and my objective is to utilize p5.js to draw on it. <div id="map"> <img src="Assets/MENA.jpg" ...

Top strategies for effectively handling Bootstrap in Python Flask projects

After putting in the effort to develop a web app using python-Flask and bootstrap for the frontend, I am excited to share my project that enables users to conveniently browse the AWS S3 bucket directly from their web browser. As this project is still a wor ...

Scraping Hidden Divs with Python's Selenium Web Automation

Currently, the objective is to extract data from a website (example) using Selenium, but encountering difficulties in accessing the concealed information within each row of the Pro Results table that remains hidden until the Show Details button (+) is clic ...

Error message: When running tests using Selenium and Python on Kubuntu 14.04, a TypeError occurs stating that the urlopen() function received multiple values for the 'body' keyword argument

When attempting to execute a selenium script in Python on Kubuntu 14.04, I encounter an error message while trying both chromedriver and geckodriver. Traceback (most recent call last): File "vse.py", line 15, in <module> driver = webdriver.Chr ...

How to review the current page in Joomla 2.5

Is there a way to determine the current page the user is visiting in Joomla 2.5? I have a code snippet that checks if the user is on the home page: $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { However, I now need a s ...

Position 2 identical classes side by side on the horizontal axis

Currently enrolled in the MIMO HTML course and facing a challenge where I am unable to align both elements with the class="column" attribute horizontally using display: inline-block; I have attempted using float:right and other CSS properties to achieve a ...

Tips for resizing a flexible circle and a definite rectangle within a stationary holder

My parent container .secondary-nav-wrap has the following CSS: .secondary-nav-wrap { margin: 30px 0; position: relative; } Within it, there is an ordered list (ol) with varying list items (li), and an absolutely positioned div .import-26-as with ...

gist-react: containing gist within a scrollable div

Struggling to contain a gist within a div with scrollbars on my next.js site using gist-react. It seems like my CSS is being overridden when the gist loads from the underlying dependency. Is there a way to achieve this without modifying the dependency itse ...

Tips for avoiding a noticeable sliding drawer when changing the direction of an HTML element

I am encountering an issue with the Daisy UI drawer component on my page. When I attempt to change the page direction using a JavaScript function, the drawer animates visibly from left to right or right to left, which is not the desired behavior. I have tr ...

What are the steps to adjusting page margins for Kindle devices?

While converting an HTML page for Kindle, I encountered a problem with multiple CSS files. The Kindle Guide recommends setting the left and right margins to 0 for normal body text in order to prevent content from falling off the edge of the screen or overl ...

arranging rows and columns in bootstrap version 4.1

Currently, I have a structure with rows and columns that I need to rearrange for mobile responsiveness. The main row consists of three columns, each containing rows in a vertical layout. Here is an example: https://i.sstatic.net/tFEhs.png For mobile view ...

What is the reason my function is only operating with a single ID?

I'm attempting to create color-changing "squares" that change color when clicked. The first square changes color correctly, but when I click on the others, the color change only happens on the first square. var image_tracker = 'red'; fu ...

List index out of range error occurs in the if-else block when the condition is met

This script retrieves data from Oddsortal website: import pandas as pd from bs4 import BeautifulSoup as bs from selenium import webdriver import threading from multiprocessing.pool import ThreadPool import os import re from math import nan class Driver: ...

Can you explain the distinction between "ExpectedConditions.visibilityOfElementLocated" and "element.isDisplayed()"?

Apologies in advance if my question seems basic, as I am new to QA and Selenium. Can someone please explain the exact difference between: wait.until(ExpectedConditions.visibilityOfElementLocated (By.xpath("//a[text()='Show adva ...

The continuous cycle of animated effects using animate.css

I've been using animate.css to add animations to my elements, and here's a snippet of the code I'm working with: <button class='animated infinite pulse tada'>1</button> <button class='animated infinite pulse ta ...

alteration of colors in a Chartist chart

Currently, I am working with a chartist graph where the colors are defined at a framework level. However, I need to make changes to the colors for a specific graph without altering the framework level settings. I attempted to create a .less file, but unfor ...

Create space in the bootstrap framework between an image and text

I'm trying to increase the space between the title/description and the icon image in my Bootstrap CSS layout. I attempted adding ms-5 to the div tag, but it didn't have the desired effect. NOTE: Please refrain from suggesting margin-right:5px as ...