81,002 questions
2355
votes
36
answers
4.0m
views
RegEx match open tags except XHTML self-contained tags
I need to match all of these opening tags:
<p>
<a href="foo">
But not self-closing tags:
<br />
<hr class="foo" />
I came up with this and wanted to make ...
2325
votes
32
answers
482k
views
How do you parse and process HTML/XML in PHP?
How can one parse HTML/XML and extract information from it?
1298
votes
41
answers
517k
views
How to remove the space between inline/inline-block elements?
There will be a 4 pixel wide space between these span elements:
span {
display: inline-block;
width: 100px;
background-color: palevioletred;
}
<p>
<span> Foo </span>
&...
596
votes
8
answers
206k
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 ...
1688
votes
50
answers
1.9m
views
How can I vertically center a div element for all browsers using CSS?
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>
<...
762
votes
11
answers
242k
views
Why does my image inside a div have extra space below it?
Why in the following code the height of the div is bigger than the height of the img ? There is a gap below the image, but it doesn't seems to be a padding/margin.
What is the gap or extra space ...
1096
votes
31
answers
2.1m
views
How can I vertically align elements in a div?
I have a div with two images and an h1. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be absolute positioned within the div.
What is the CSS ...
1090
votes
10
answers
719k
views
What is a clearfix?
Recently I was looking through some website's code, and saw that every <div> had a class clearfix.
After a quick Google search, I learned that it is for IE6 sometimes, but what actually is a ...
2853
votes
43
answers
2.0m
views
Make a div fill the height of the remaining screen space
I am working on a web application where I want the content to fill the height of the entire screen.
The page has a header, which contains a logo, and account information. This could be an arbitrary ...
247
votes
18
answers
84k
views
Using regular expressions to parse HTML: why not?
It seems like every question on stackoverflow where the asker is using regex to grab some information from HTML will inevitably have an "answer" that says not to use regex to parse HTML.
Why not? I'm ...
3080
votes
22
answers
2.2m
views
How do I modify the URL without reloading the page?
Is there a way I can modify the URL of the current page without reloading the page?
I would like to access the portion before the # hash if possible.
I only need to change the portion after the domain,...
12
votes
4
answers
11k
views
javascript function doesn't work when link is clicked
I have a fairly simple page with a sidebar nav and an iFrame in which to load content.
I want to change the content of the of the iFrame by clicking on links in the sidebar nav. I'm using the ...
110
votes
4
answers
49k
views
Make container shrink-to-fit child elements as they wrap [duplicate]
I'm trying to figure out how flexbox works (supposed to work?…) for cases like below:
.holder {
width: 500px;
background: lightgray;
display: flex;
flex-direction: row;
justify-content: ...
746
votes
8
answers
907k
views
How to affect other elements when one element is hovered
What I want to do is when a certain div is hovered, it'd affect the properties of another div.
For example, in this JSFiddle demo, when you hover over #cube it changes the background-color but what I ...
356
votes
34
answers
258k
views
How do you get the footer to stay at the bottom of a Web page?
I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in all browsers. It ...
571
votes
30
answers
560k
views
How to center an element horizontally and vertically
I am trying to center my tabs content vertically, but when I add the CSS style display:inline-flex, the horizontal text-align disappears.
How can I make both text alignments x and y for each of my ...
2551
votes
30
answers
1.6m
views
How do I reduce the opacity of an element's background using CSS?
Is it possible, using CSS only, to make the background of an element semi-transparent but have the content (text & images) of the element opaque?
I'd like to accomplish this without having the ...
2706
votes
44
answers
2.8m
views
How to make a div 100% height of the browser window
I have a layout with two columns - a left div and a right div.
The right div has a grey background-color, and I need it to expand vertically depending on the height of the user's browser window. Right ...
1305
votes
32
answers
890k
views
How can I tell if a DOM element is visible in the current viewport?
Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the viewport)?
(The question refers to Firefox.)
308
votes
25
answers
304k
views
Can scripts be inserted with innerHTML?
I tried to load some scripts into a page using innerHTML on a <div>. It appears that the script loads into the DOM, but it is never executed (at least in Firefox and Chrome). Is there a way to ...
91
votes
2
answers
127k
views
Why is percentage height not working on my div? [duplicate]
I have two divs with a height of 90%, but the display is different.
I have tried to put an outer div around them, but that has not helped. Also, it's the same on Firefox, Chrome, Opera, & Safari....
1610
votes
36
answers
2.4m
views
How do I vertically align text in a div?
I am trying to find the most effective way to align text with a div. I have tried a few things and none seem to work.
.testimonialText {
position: absolute;
left: 15px;
top: 15px;
...
29
votes
3
answers
9k
views
Why are inline event handler attributes a bad idea in modern semantic HTML?
Is inline event handlers considered a bad practice?
For example: <button onclick=someFunction()>Click me!</button>
If so, what are the disadvantages of using inline event handlers?
435
votes
14
answers
388k
views
Why does this CSS margin-top style not work?
I tried to add margin values on a div inside another div. All works fine except the top value, it seems to be ignored. But why?
What I expected:
What I get:
Code:
#outer {
width: 500px;
...
48
votes
4
answers
53k
views
Understanding CSS selector priority / specificity
I'd like to understand how CSS selectors work with property collisions. How is one property selected over another one?
div {
background-color: red;
}
div.my_class {
background-color: ...