What is the best way to select both an inline element and a block-level element at the same time?

After receiving a shortcode from a WordPress theme, the output is:

<div class="heading clearfix"><i class="icon icon-list-ol h2"></i> <h2> Hello World! </h2></div>

I am looking to style both the icon and h2 elements together. How can I target them simultaneously?

I attempted the following code:

i.icon.icon-list-ol.h2  h2 {color:red;}

Unfortunately, it did not work.
PS: This shortcode was generated by a WordPress theme.

Answer №1

Use a comma to distinguish them:

i.icon.icon-list-ol.h2, h2 {color:red;}

Answer №2

Give this a go:

div.subheading i.icon,
div.subheading h2 {
    color:blue;
}

Answer №3

Give this a shot

i.icon.icon-list-ol.h2 + h2 {color:red;}

Check out the demo

Answer №4

Why

.icon , .h2 { color : red; }

is it not functioning correctly?

Answer №5

Divide i.icon.icon-list-ol.h2 h2 using a comma(,)

To modify the code in css, you need to make the following adjustment:

i.icon.icon-list-ol.h2, h2 {color:red;}

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

Customizing the hover behavior of a div element without causing displacement of surrounding elements

I am facing an issue where the descriptions in my list of 100 items are longer than the width of the div, causing the text to be cut off. I want to display the full description on hover without affecting the layout of other items. Currently, when I hover o ...

What is the best way to load the nested array attributes in an HTML table dynamically with AngularJS?

I attempted the following code, but I am only able to access values for cardno and cardtype. Why can't I access the others? Any suggestions? <tr ng-repeat="data in myData17.layouts"> <td ng-show="$index==1">{{data.name}}</td> &l ...

What could be the reason for my Form styling failure?

Currently working on freecodecamp's portfolio creation exercise. It should be a straightforward task, but I'm facing a small issue that's puzzling me. I'm trying to remove the border and outline (when focused) from my contact-area form ...

The navigation underline stays in place even after being clicked, and also appears below

Take a look at this js fiddle I've managed to create the underline effect on the navigation links when the user hovers over them. However, the underline only stays visible until the user clicks elsewhere on the screen. How can I make it persist as l ...

Load images in advance using jQuery to ensure they are cached and retrieve their original sizes before other activities can proceed

When a user clicks on a thumbnail, I aim to display the full-size image in a div. To achieve this, I want to determine the original size of the image based on its source URL before it loads, allowing me to set the appropriate dimensions for the container. ...

Exclusive Checkbox Update

My code is causing me some trouble. When I click the update button, I want to only display the checked fields from the checkboxes on the redirected page. Below, I will share the code from the initial page, followed by the code from the second page where t ...

How come my "Pop-up box" doesn't appear when clicked a second time?

Although the code above works perfectly when I run it, it causes errors on my website. The issue I'm facing is that on the first click, all links work fine. However, when I try to click a second time, it shows a blank page and I can't click anywh ...

Using Javascript to dynamically add variables to a form submission process

Looking to enhance my javascript skills, I've created a script that locates an existing id and exchanges it with a form. Inside this form, I'm aiming to incorporate javascript variables into the submit url. Unsure if this is feasible or if I&apo ...

The v-for directive on a reactive Vuejs array is failing to render its elements

After much searching, I have identified the error and provided a brief explanation in the following paragraph. The code below resolves the error by changing the approach of the code rather than fixing the error itself. By defining the indexes of the array ...

"Trying to activate a hover effect on a div using JQuery, but it's not functioning

Is there a way to make these divs animate each time I hover over them? Currently, the animation only works once and does not repeat when hovering again. Can anyone provide guidance on how to achieve this? function Rotate() { $('#gear1,#gear2,#gea ...

A guide on incorporating multiple nested loops within a single table using Vue.js

Is it possible to loop through a multi-nested object collection while still displaying it in the same table? <table v-for="d in transaction.documents"> <tbody> <tr> <th>Document ID:</th> &l ...

The descendant selector in CSS fails to apply changes to the element

I am struggling to modify the border of a specific descendant element and so far I have not been successful. Despite using the correct descendant selector in the HTML below, the style change is not taking effect. If anyone has any insights on what could be ...

JavaScript allows for the creation of a border around an iframe using the

In order to improve the speed of my search engine, I am implementing lazy loading by using numerous iframes to display various elements of the results. Within the JavaScript code that connects the element ID to the creation of the iframe, I have set the fr ...

Adjust the size of the tabs in CodeSlider

I've implemented a jQuery plugin found here. This is the HTML I'm using: <div class="account_window" style="display:none;"> <div class="coda-slider" id="slider-id"> <div> <h2 class="title">Option1< ...

Encountering a classnotfound exception with JSP JDBC SERVLET, but all code appears to be

index.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> < ...

Retain the input values even after the page is refreshed

I have developed a simple form validation page in ReactJS. The input fields are validated using regex patterns. One issue I encountered is that if I enter data in the input fields and refresh the page before completing the form, the input fields are clear ...

Above, there are two components with a scrollbar, while below there is a fixed div that remains in place when the screen

Just a heads up: below is an example with code of how I envision my interface to look, but I'm not sure if it's valid? I've been trying to create an HTML5/CSS interface that resembles the MIRC fullscreen layout (check out the image below) a ...

PHP mistakenly outputs content that is not enclosed within tags

After discovering StackOverflow, I couldn't resist sharing my PHP code conundrum with the incredible community here! So, in a WordPress template, I have this chunk of PHP: echo '<div class="thumbnail">'; echo the_post_thumbnail(); ec ...

Is there a way to do HTML select-option in a reversed order?

Having an issue with my HTML select element: <select> <option>...</option> <option>...</option> <option>...</option> </select> Currently, all the options are displayed below the select field. I ...

Tips for achieving vertically centralized components with uniform height columns in Bootstrap 4

I tried implementing the solution provided in this question: Bootstrap 4 vertical center - equal height cards However, I am still facing an issue. Despite applying the suggested code: <div class="cycle-des h-100 justify-content-center">Product Cycl ...