Skip to main content

All Questions

0 votes
1 answer
25 views

Precedence in parent/child classes of same specificity [duplicate]

In the given code snippet why font size of h1 element is 36px? I have these questions : If h1 is defined 1st, then the font size of main(i.e. 32px) should be applied on the h1 heading, as it is ...
Shubhang Sahu's user avatar
4 votes
1 answer
96 views

Why is the font-size, but not the color, property applying to elements?

I'm self-teaching myself Html/Css, kindly explain to me like a dummy(phew!) Help clear the doubt where I tried to target my list items in an unordered list. I realized that color property couldn't be ...
Polycarp Angololo's user avatar
1 vote
2 answers
59 views

CSS Specificity - Conflicts between CSS selectors

I have a question regarding the following pseudo-class selector. Even with !important, the text under this li:first-child is not showing blue. p has Selector Specificity: (0, 0, 1) li:first-child has ...
Jeffrey's user avatar
  • 113
0 votes
1 answer
20 views

Rules Specificity [duplicate]

body { font-size: 12px; } .brown { color: brown; font-weight: 200; } .large { font-size: 28px; } .normal { font-size: 18px; color: blue; font-weight: 700; } <html> <head&...
Raphael Lanz's user avatar
1 vote
2 answers
855 views

Can't change the style of link

I'm very new to coding and I currently try to change the style of my html link. I've nested my Picture, <h1> and <p> in a <a href> to make it all a link to the same destination, but ...
user16716646's user avatar
0 votes
0 answers
16 views

How is css specificity determined for elements with the same selector? [duplicate]

I have two styles affecting the same element (myDiv) from different stylesheets. Stylesheet1.css .myDiv{ background-color:#000; } Stylesheet2.css .myDiv{ background-color:#FFF; } Neither style ...
Urbycoz's user avatar
  • 7,431
0 votes
1 answer
40 views

Am I messing with specificity ? What's going on?

I will short and clear. I have this html code snippet. <nav> <span class="heading"><a href="#">CodingHero</a></span> <ul> ...
Biebk's user avatar
  • 161
2 votes
1 answer
1k views

Why font-size defined at :root is overriden by user agent stylesheet? If it's intended to be, then how is th snippet supposed to work?

My understanding is that the CSS in the following snippet is for having font-size vary gradually with the viewport, a possiple building block to accomplish responsive design: :root { font-size: ...
Enlico's user avatar
  • 28.9k
1 vote
2 answers
226 views

Why setting max-width makes setting width with a more specific selector ineffective?

In the following snippet, I'm specifying the width in pixel of the image using the img.icon selector. However, as I down-resize the browser the image also shrinks. If I remove the commented line, then ...
Enlico's user avatar
  • 28.9k
0 votes
1 answer
53 views

Styling an element within another styled as a pseudo element first-line

I am using a pseudo-element to style the first line of a paragraph (class="first-para") in my document: .first-para::first-line { font-weight: bold; font-size: calc(var(--fontSize) * 1....
Paul's user avatar
  • 3
1 vote
0 answers
39 views

CSS add specificity to :host pseudo class [duplicate]

I'm trying to add specificity to the :host pseudo class so that it doesn't get overridden by the universal (*) selector outside the custom element. I see that adding a selector in the :host function ...
Mendy's user avatar
  • 8,752
0 votes
0 answers
25 views

Descendant selectors more specific than child selectors? [duplicate]

So I'm learning CSS right now. I'm tinkering with selectors at the moment and this has me kind of stumped. When I run this code. The child of the li all stay green. ul li{ color: green; } li >...
Lazaro's user avatar
  • 17
-1 votes
1 answer
1k views

CSS Wildcard Selector - No override?

Can anyone tell me why the last span is dotted? Why isn't it overwritten? Forkable pen https://codepen.io/anon/pen/pqjREd div div div * span { border: double; } div * * span { border: ...
user10320374's user avatar
2 votes
2 answers
10k views

How to separate css rules for files in react?

I am working on two pages in reactjs. One is a landing page and the other is an articles page. The problem I am having is the CSS rules for the landing page are affecting the appearance of the ...
frre tyy's user avatar
  • 363
1 vote
2 answers
110 views

Does CSS ever care about DOM "closeness" relationships?

Given the following code: div, span { padding: 10px; display: block; } .light-background { background-color: #cacaca; } .dark-background { background-color: #333; } .dark-background ...
mindfullsilence's user avatar

15 30 50 per page