All Questions

2281
votes
26answers
1312621 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 ...
781
votes
33answers
190521 views

How do I remove the space between inline-block elements?

Given this HTML and CSS: span { display:inline-block; width:100px; background-color:palevioletred; } <p> <span> Foo </span> <span> Bar </span...
3357
votes
80answers
3271078 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>
930
votes
12answers
408565 views

Is there a "previous sibling" CSS selector?

+ is for the next sibling. Is there an equivalent for the previous sibling?
665
votes
66answers
418347 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 ...
94
votes
1answers
3923 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,...
319
votes
4answers
59017 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:                        &...
76
votes
1answers
6649 views

Why don't flex items shrink past content size?

I have 4 flexbox columns and everything works fine, but when I add some text to a column and set it to a big font size, it is making the column wider than it should be due to the flex property. I tri...
721
votes
18answers
441489 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...
984
votes
40answers
1040282 views

How to vertically center a div for all browsers?

I want to center a div vertically with CSS. I don't want tables or Javascript, but only pure CSS. I found some solutions, but all of them are missing Internet Explorer 6 support. <body> <...

Previous Next