Safari does not support the use of nth-child

My CSS code is functioning properly in Firefox and Chrome but not in Safari (5.1). Even though I have confirmed that Safari supports nth-child, it still does not work. Can someone please help me identify what I'm doing wrong?

CSS:

option:nth-child(2){
    display: none;
  }
  

HTML:

<select>
     <option value="1">One</option>
     <option value="2">Two</option>
     <option value="3">Three</option>
  </select>

Demo: http://jsfiddle.net/Kv9tj/

Answer №1

If you ever find yourself in need, try using: nth-of-type(2) .

The browser compatibility for :nth-of-type is quite good... Firefox 3.5+, Opera 9.5+, Chrome 2+, Safari 3.1+, IE 9+.

Wishing you success with this tip!!!

Answer №2

The issue you're experiencing may not be related to the nth-child selector, but rather caused by using display: none on option elements.
You can refer to this helpful answer for more insights: (pertaining to a similar query).

It has been noted that applying display: none to option in Safari or IE may not yield the expected results.

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

Activate the CSS on a click event using the onClick method

I am trying to implement a transition that triggers when clicking on a specific div element. Currently, the transition only occurs with the active css class. How can I achieve this effect by simply clicking on the div itself? I am using reactjs and believe ...

Trouble selecting options in hierarchical data

I've been attempting to run this sample code for selecting an option from a select element with hierarchical data, but it seems to be having some issues. $scope.options = [ { id: 1, info: { label: "Item 1" } }, { id: 2, info: { label: ...

A step-by-step guide on retrieving DOM elements in Selenium after a click event

My goal is to use Selenium to retrieve the HTML of a page after clicking on a link. However, I encountered a challenge as simply downloading the link did not work in this case. When the link is clicked, some obfuscated Javascript is triggered which loads d ...

Issues with the bootstrap 4 modal update

I am currently working on an app in Spring Boot with JSP for the frontend, and I have encountered a specific issue: In my application, there is a table with multiple rows where I can click a button to update each row as needed. When I click on one row and ...

Incorporating SCSS directly in React component along with material-ui styling

I'm having trouble incorporating styles into my React component. I'd prefer to use SCSS instead of either using the withStyle function or importing a plain CSS file into a JS file. For instance, I would like to import my SCSS file into ButtonCom ...

Is there a way for me to have a table automatically scrolled to a specific column upon loading the HTML page?

My table contains a dynamic number of columns based on the months inputted from the database starting from a start_date and ending at an end_date. I have the current_date stored as a variable and want the table to load with the x-scrollbar positioned right ...

Locate a list item within an unordered list and proceed with a comparison

Looking for a way to target an li within a specific ul that has a data-rank higher than the others, and apply different styling to it in comparison to its sibling li. Is there a smart approach to achieve this using regular CSS or styled components? <ul ...

What are some tips for managing the hover effect using CSS3?

Here's a demonstration of my current setup. When you hover over the black box, a transition occurs and reveals my tooltip. However, I only want the tooltip to appear when hovering over the black box itself. Currently, the transition also triggers if y ...

Implementing a feature that ensures html elements are transparent in a PDF conversion

I am in the process of converting a webpage into a format that is easily printable as a PDF, while ensuring that it maintains the same appearance. Many tools for printing to PDF do not support background images or colors, so I am attempting to overcome thi ...

Ways to determine if content is visible within a div

My website contains a script that brings in content from an ad network and displays it within a div element. Unfortunately, this particular ad network only fills ads 80% of the time, leaving the remaining 20% of the time without any ads to display. This la ...

Revise the color of the selected image

click here for image description I'd like the area's color to change when the mouse hovers over it. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA ...

Preventing Button Shifting in CSS: A Guide

I have a website at antetech.org where I am using bttn.css for the navigation buttons. The issue I am facing is that when I hover over a button, the letter-spacing doubles, causing all the buttons to the left to shift over. Is there a way to maintain the l ...

Can you explain the purpose of using the "overlay" value in the "overflow" property?

Can someone please clarify the distinction between "overlay" and "auto" for me? Is the function of "overlay" similar to that of "auto"? ...

PHP Mysqli - modifying data but encountering truncated items

I'm in the process of building a CRUD system, and I've encountered an issue on my edit page where the data being retrieved is getting cut off after the first space. For instance, if the company name in the database record is Stack Overflow, when ...

Links in the navigation bar can be clicked on, however they are not visible when

The screenshot of the error The menu links in the mobile view aren't visible but clickable. As a novice in HTML and CSS, I'm facing an issue where the hamburger menu with z-index 1 is displayed correctly, but its content is not visible. This prob ...

How can I ensure text remains within a parent div and is positioned above an image?

After writing the following HTML and CSS, an issue arose when resizing the page: <div style="position: relative;"> <img width="100%" src="images/some.jpg"> <div class="header"> <h1>my header</h1> ...

Is there a way to showcase posts with a certain tag in a single column on my tumblr theme, while reserving the other column for posts aimed at the wider audience?

I am interested in customizing my theme so that one section on the homepage of my blog only shows posts with a specific tag (such as "mine" or "personal"), while another section displays all posts, regardless of tags. Although I have searched through simi ...

Simple Method To Dynamically Align jQuery LightGallery Thumbnails On a Responsive CSS Website

Can anyone assist me quickly? I've implemented everything but am facing a slight issue with the centering of my ul code. I've tried various solutions without success. Here is my code, any advice would be greatly appreciated (I may sound stressed ...

Limit the ability to zoom in a webview application

I am facing an issue with my Android WebView app that is designed to load a specific URL and display it along with its links within the app. Despite setting the webpage size to 720px x 1280px using CSS to fit the screen of a Galaxy S3, I am encountering di ...

What is the best way to send props to a styled component without needing to convert them to transient props beforehand

Recently, I designed a custom Text component that accepts several props. These props are then forwarded to the styled component where specific styles are applied. However, I am facing an issue where I do not want these props to be passed down to the DOM, b ...