All Questions

1609
votes
33answers
2401368 views

How do I vertically center text with CSS?

I have a div element which contains text, and I want to align the contents of this div vertically center. Here is my div style: #box { height: 170px; width: 270px; background: #000; ...
152
votes
8answers
47488 views

Regular expression pattern not matching anywhere in string

I am trying to match <input> type “hidden” fields using this pattern: /<input type="hidden" name="([^"]*?)" value="([^"]*?)" />/ This is sample form data: <input type="hidden" n...
368
votes
12answers
36029 views

Can you provide some examples of why it is hard to parse XML and HTML with a regex?

One mistake I see people making over and over again is trying to parse XML or HTML with a regex. Here are a few of the reasons parsing XML and HTML is hard: People want to treat a file as a sequence...
1890
votes
26answers
1468357 views

How do I give text or an image a transparent 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 te...
712
votes
17answers
291540 views

Maintain the aspect ratio of a div with CSS

I want to create a div that can change its width/height as the window's width changes. Are there any CSS3 rules that would allow the height to change according to the width, while maintaining its asp...
819
votes
10answers
542343 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 c...
3501
votes
51answers
2042979 views

Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?

The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.? func...
693
votes
23answers
332292 views

How to 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 regards Firefox)
1042
votes
19answers
396952 views

Where should I put <script> tags in HTML markup?

When embedding JavaScript in an HTML document, where is the proper place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place these in the <he...
27
votes
2answers
34348 views

Flexbox code working on all browsers except Safari. Why?

Grid columns with list tags, I need to display in correct order per every 3 columns, with auto width enabled for every extra HTML list elements. This is my example: <style> ul { ...

Previous Next