Can I use a :before or :after pseudo-element on an input field?

:before and :after render inside a container and <input> can not contain other elements. Pseudo-elements can only be defined (or better said are only supported) on container elements. Because the way they are rendered is within the container itself as a child element. input can not contain other elements hence they’re not supported. A button … Read more

CSS Background Opacity [duplicate]

Children inherit opacity. It’d be weird and inconvenient if they didn’t. You can use a translucent PNG file for your background image, or use an RGBa (a for alpha) color for your background color. Example, 50% faded black background: <div style=”background-color:rgba(0, 0, 0, 0.5);”> <div> Text added. </div> </div>

Should I make HTML Anchors with ‘name’ or ‘id’?

According to the HTML 5 specification, 5.9.8 Navigating to a fragment identifier: For HTML documents (and the text/html MIME type), the following processing model must be followed to determine what the indicated part of the document is. Parse the URL, and let fragid be the <fragment> component of the URL. If fragid is the empty … Read more

How to select a radio button by default? [duplicate]

XHTML solution: <input type=”radio” name=”imgsel” value=”” checked=”checked” /> Please note, that the actual value of checked attribute does not actually matter; it’s just a convention to assign “checked”. Most importantly, strings like “true” or “false” don’t have any special meaning. If you don’t aim for XHTML conformance, you can simplify the code to: <input type=”radio” … Read more

Can I write a CSS selector selecting elements NOT having a certain class or attribute?

Typically you add a class selector to the :not() pseudo-class like so: :not(.printable) { /* Styles */ } :not([attribute]) { /* Styles */ } But if you need better browser support (IE8 and older don’t support :not()), you’re probably better off creating style rules for elements that do have the “printable” class. If even that … Read more

Space between two rows in a table?

You need to use padding on your td elements. Something like this should do the trick. You can, of course, get the same result using a top padding instead of a bottom padding. In the CSS code below, the greater-than sign means that the padding is only applied to td elements that are direct children … Read more

Limit file format when using ?

Strictly speaking, the answer is no. A developer cannot prevent a user from uploading files of any type or extension. But still, the accept attribute of <input type = “file”> can help to provide a filter in the file select dialog box provided by the user’s browser/OS. For example, <!– (IE 10+, Edge (EdgeHTML), Edge … Read more