the child element is not being targeted

My confusion lies in the fact that I am unable to realize how to properly use this. My goal is to specifically target the pre tag only when it appears within a description.

p.description > pre{color:red}
<p class="description">
    <pre> adsfasdf asdf asdf asdf asdf asf sd f</pre>
</p>

In this scenario, the parent of pre is p.description, so why isn't it being selected? Despite examining various other discussions on this topic, I am struggling to identify my mistake.

Answer №1

Are you specifically requiring the parent container to have a p tag?

If not, consider changing it to a div:

div.description pre {
    color: red;
}
<div class="description">
    <pre> adsfasdf asdf asdf asdf asdf asf sd f</pre>
</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

How to position button components at the center in a NextJS application?

Incorporating a button within my nextjs page has been a challenge as I am striving to position it in the center of the page for optimal viewing on both PCs and mobile devices. Despite various attempts, the button remains fixed on the far left side of the p ...

Creating a radial gradient texture using CSS

I'm encountering an issue with my radial gradient and texture combination. Here is the code snippet I am using: background-image: url('../img/texture.png'); /* fallback */ background: -moz-radial-gradient(rgba(253,253,253,0.1) 0%, rgba(2 ...

Excessive Expansion of Website Width

Initially, I crafted a website on my local server, and it had the ideal width. Afterwards, I uploaded it to the live server and made some design modifications. To my surprise, there is now an unexpected scroll bar at the bottom of the page, causing the s ...

How can I place a div using pixel positioning while still allowing it to occupy space as if it were absolutely positioned?

I successfully created an slds path element with multiple steps. I want to display additional subtext information below each current step, but there might not always be subtext for every step. To achieve this, I created an absolute positioned div containi ...

Adding a sub-menu to a dropdown menu in your Blogger website can enhance navigation and improve

Having some trouble adding a "sub menu" to my drop down menu. I have limited knowledge of CSS and can't seem to figure it out. My goal is to make the sub-menu open to the right side when the cursor is placed on it. Below is the related CSS and HTML co ...

Show a grid layout featuring varying heights using HTML

I am trying to create a grid view for displaying images in an HTML document. I want each li tag to have a different height, but currently they are all the same height. Below is my HTML code: <div class="blog_main_midd_section"><ul> ...

What is the best way to ensure a NavBar stays at the top of the page when it is not collapsed?

I have integrated a NavBar using Bootstrap 5, which functions flawlessly. However, I am facing a specific issue that I haven't been able to resolve yet: When a user increases their screen size to <300%, it triggers the collapse button to appear. I ...

In IE, the hover state of the background color and sub menu is frequently toggling

I've been struggling with this issue all week. I have a CSS dropdown menu that uses both standard lists and content boxes as sub menus. The problem lies in IE, where each LI has an anchor tag that is set to display block in order to fill the parent LI ...

The max-height property is not applied to a border-box div with padding

One technique we use is the percentage trick on paddings to maintain aspect ratio in a div as the user scales their window. Here's an example: .div { background: red; width: 80%; margin: 0 auto 10px; -webkit-box-sizing: border-box; ...

What are some tips for customizing the NavBar Bootstrap 4 Layout to fit a unique design?

Good evening everyone, I am currently working on a website project for a client who has provided me with specific requirements for the Navbar design. While it seemed straightforward at first, I have spent several hours trying to perfect the layout. I am ...

Set the position to fixed so it doesn't scroll

Is there a way to create a fixed position div that remains in place when the user scrolls, similar to the effect shown in this example image? Position Absolute: https://i.sstatic.net/4RAcc.png Position Fixed (desired effect): https://i.sstatic.net/3DIna. ...

Tips on creating a dropdown menu with a fontawesome icon

I'm brand new to coding and struggling to create a drop-down menu similar to the one used in fonawsome fa fa-ellipsis-v While I'm attempting to code it here, I'm not sure why the class is being overridden. *{ margin: 0; padding : ...

Curating personalized designs within a content management system

Currently, I am developing a SaaS platform that will feature customized styles for user accounts. The current method involves using YAML to create unique stylesheets for each account. However, as the number of accounts increases, I am starting to question ...

Include a return or delete from the default IO statement

I am utilizing an intersection observer that alters the header's font-color and background-color based on the content intersecting with it. This change is determined by the presence of data-color and data-background attributes declared on the div/sect ...

Having trouble with Markdown rendering on Jekyll? My suspicion is that CSS may be causing the issue

I am a member of a CTF team that has a GitHub Pages website using Jekyll, but for some reason the markdown rich text is not displaying correctly. I believe the issue lies within the CSS rather than being related to Jekyll or the markdown renderer, but I&ap ...

Sidebar Text Remains Visible Despite Collapsed Sidebar

I'm working on implementing a sidebar shrink effect when collapsing it using a combination of custom CSS, jQuery, and Bootstrap. The custom CSS and jQuery handle the shrinking effect, while Bootstrap is used for styling purposes. However, I am facing ...

Comparison of Chrome's compatibility with Bootstrap and Edge

Firefox Safari I am facing an issue that seems obvious, but I am unable to pinpoint the exact cause. It just doesn't seem right for no apparent reason. is the website in question. I have tried various troubleshooting methods such as inspecting th ...

List style image does not serve its intended purpose

I attempted to personalize my webpage by adding an image to a list, but I couldn't get the list-style image to work. You can view the page at Below is the code I used: CSS /* Fleet List */ ul#flotta li { list-style-image:url("http://ctp.serviziew ...

Stylesheet for Foundation Buttons in CSS/SASS

I am currently working on customizing the appearance of Zurb Foundation using SASS/CSS. However, I am facing an issue with the buttons. There seems to be a highlight at the top of the buttons that gives them a traditional button look, which I want to remov ...

When the height of the first div increases, make sure the second div gets pushed down

Currently, I am working on creating accordion buttons that are wrapped within a div container. The goal is to keep them in a grid layout with 2 columns like the image below: https://i.sstatic.net/SmfYx.png However, when one of the accordion buttons is op ...