How to Target Elements with IDs Containing \'Some:Same\' and Ending with \'name\' using CSS?

Patricia Arquette
Release: 2024-10-27 11:34:02
Original
194 people have browsed it

How to Target Elements with IDs Containing

CSS Selector for Elements with IDs Containing Specific Text

Problem:

Consider HTML elements with IDs in the format "someGenerated Some:Same:0:name" or "someGenerated Some:Same:0:surname." How can we use CSS to select only those elements with IDs containing "Some:Same" and ending with "name"?

Solution:

Using the following CSS selector accomplishes this:

a[id*='Some:Same'][id$='name']
Copy after login

Explanation:

  • a[id*='Some:Same']: Selects all a elements whose IDs contain the string "Some:Same." The asterisks (*) are used as wildcards, allowing any characters before or after "Some:Same."
  • [id$='name']: Selects all elements whose IDs end with "name." The dollar sign ($) is used as a wildcard at the end of the string.

By combining these selectors, we can isolate the specific a elements with IDs containing "Some:Same" and ending with "name."

The above is the detailed content of How to Target Elements with IDs Containing \'Some:Same\' and Ending with \'name\' using CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!