All Questions

2247
votes
25answers
1287114 views

Is there a CSS parent selector?

How do I select the <li> element that is a direct parent of the anchor element? In example my CSS would be something like this: li < a.active { property: value; } Obviously there are ...
766
votes
32answers
187325 views

How to remove the space between inline-block elements?

Given this HTML & CSS: span { display:inline-block; width:100px; background-color:palevioletred; } <p> <span> Foo </span> <span> Bar </s...
3317
votes
79answers
3228853 views

How to horizontally center a <div> in another <div>?

How can I horizontally center a <div> within another <div> using CSS (if it's even possible)? <div id="outer"> <div id="inner">Foo foo</div> </div>
665
votes
66answers
415778 views

Why not use tables for layout in HTML?

It seems to be the general opinion that tables should not be used for layout in HTML. Why? I have never (or rarely to be honest) seen good arguments for this. The usual answers are: It's good to ...
913
votes
12answers
399429 views

Is there a "previous sibling" CSS selector?

+ is for the next sibling. Is there an equivalent for the previous sibling?
90
votes
1answers
3858 views

Example images for code and mark-up Q&As

When preparing an MCVE/SSCCE that involves images, it is useful to have direct access to images. The types of images that would cover most questions are - small images in multiple colors or shapes,...
302
votes
4answers
55445 views

In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?

Consider the main axis and cross axis of a flex container:                        &...
709
votes
18answers
435002 views

Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery

Is there any way to select/manipulate CSS pseudo-elements such as ::before and ::after (and the old version with one semi-colon) using jQuery? For example, my stylesheet has the following rule: .spa...
67
votes
1answers
5864 views

Why doesn't flex item shrink past content size?

I have 4 flexbox columns and everything works fine, but when I add some text to column and set it to a big font size, it is making the column wider than it should be due to flexbox setting. I tried t...
982
votes
8answers
312571 views

Which characters are valid in CSS class names/selectors?

What characters/symbols are allowed within CSS class selectors? I know that the following characters are invalid, but what characters are valid? ~ ! @ $ % ^ & * ( ) + = , . / ' ; : " ? > < ...

Previous Next