Questions tagged [html]

HTML (HyperText Markup Language) is the markup language for creating web pages and other information to be displayed in a web browser. Questions regarding HTML should include a minimal reproducible example and some idea of what you're trying to achieve. This tag is rarely used alone and is often paired with CSS and JavaScript.

html
Filter by
Sorted by
Tagged with
8795 votes
9 answers
777k views

Why does HTML think “chucknorris” is a color?

Why do certain random strings produce colors when entered as background colors in HTML? For example, bgcolor="chucknorris" produces a red background: <body bgcolor="chucknorris"> ...
user456584's user avatar
  • 87.7k
5474 votes
79 answers
4.7m views

How can I validate an email address in JavaScript?

I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?...
5186 votes
68 answers
4.9m views

How do I check whether a checkbox is checked in jQuery?

I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery. For example, if the age checkbox is checked, then I need to show a textbox to enter ...
5097 votes
131 answers
4.9m views

How can I horizontally center an element?

How can I horizontally center a <div> within another <div> using CSS? <div id="outer"> <div id="inner">Foo foo</div> </div>
4432 votes
56 answers
2.5m 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.? ...
4389 votes
43 answers
2.0m views

Change an HTML input's placeholder color with CSS

Chrome v4 supports the placeholder attribute on input[type=text] elements (others probably do too). However, the following CSS doesn't do anything to the placeholder's value: input[placeholder], [...
3696 votes
19 answers
2.7m views

Set cellpadding and cellspacing in CSS?

In an HTML table, the cellpadding and cellspacing can be set like this: <table cellspacing="1" cellpadding="1"> How can the same be accomplished using CSS?
kokos's user avatar
  • 43.4k
3417 votes
34 answers
3.5m views

How can I change an element's class with JavaScript?

How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?
Nathan Smith's user avatar
  • 37.3k
3270 votes
22 answers
1.8m views

How do I disable the resizable property of a textarea?

I want to disable the resizable property of a textarea. Currently, I can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse. How can I disable this?
user549757's user avatar
  • 33.3k
3223 votes
104 answers
1.4m views

How do you disable browser autocomplete on web form field / input tags?

How do you disable autocomplete in the major browsers for a specific input (or form field)?
Brett Veenstra's user avatar
3177 votes
20 answers
292k views

Is it possible to apply CSS to half of a character?

What I am looking for: A way to style one HALF of a character. (In this case, half the letter being transparent) What I have currently searched for and tried (With no luck): Methods for styling half ...
SimplyAzuma's user avatar
  • 25.5k
3072 votes
24 answers
1.5m views

How to store objects in HTML5 localStorage/sessionStorage

I'd like to store a JavaScript object in HTML5 localStorage, but my object is apparently being converted to a string. I can store and retrieve primitive JavaScript types and arrays using localStorage, ...
Kristopher Johnson's user avatar
3066 votes
40 answers
2.5m views

How can I know which radio button is selected via jQuery?

I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery? I can get all of them like this: $("form :radio") How do I know which one is selected?
juan's user avatar
  • 81.1k
3026 votes
21 answers
2.1m 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,...
Robin Rodricks's user avatar
2909 votes
16 answers
2.4m views

I need an unordered list without any bullets

I have created an unordered list. I feel the bullets in the unordered list are bothersome, so I want to remove them. Is it possible to have a list without bullets?
praveenjayapal's user avatar
2763 votes
37 answers
4.3m views

How do I vertically center text with CSS? [duplicate]

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; ...
Irakli Lekishvili's user avatar
2753 votes
43 answers
1.8m 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 ...
Vincent McNabb's user avatar
2699 votes
37 answers
9.6m views

How do I create an HTML button that acts like a link?

How do I create an HTML button that acts like a link? So that clicking the button redirects the user to a page. I want it to be accessible, and with minimal extra characters or parameters in the URL.
Andrew's user avatar
  • 233k
2669 votes
43 answers
2.7m 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 ...
mike's user avatar
  • 26.8k
2537 votes
29 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 ...
Stijn Sanders's user avatar
2501 votes
44 answers
1.9m views

How can I make a div not larger than its contents?

I have a layout similar to: <div> <table> </table> </div> I would like for the div to only expand to as wide as my table becomes.
user avatar
2445 votes
21 answers
2.2m views

Get the size of the screen, current web page and browser window

How can I get windowWidth, windowHeight, pageWidth, pageHeight, screenWidth, screenHeight, pageX, pageY, screenX, screenY which will work in all major browsers?
turtledove's user avatar
  • 25.7k
2312 votes
32 answers
476k views

How do you parse and process HTML/XML in PHP?

How can one parse HTML/XML and extract information from it?
2307 votes
31 answers
2.4m views

Retrieve the position (X,Y) of an HTML element

I want to know how to get the X and Y position of HTML elements such as img and div in JavaScript.
user avatar
2289 votes
27 answers
554k views

HTML: Valid id attribute values?

When creating the id attributes for HTML elements, what rules are there for the value?
Mr Shark's user avatar
  • 26.2k
2283 votes
14 answers
1.1m views

How can I select an element with multiple classes in jQuery?

I want to select all the elements that have the two classes a and b. <element class="a b"> So, only the elements that have both classes. When I use $(".a, .b") it gives me the union, but I ...
Mladen's user avatar
  • 25.7k
2256 votes
26 answers
1.6m views

Vertically align text next to an image?

Why won't vertical-align: middle work? And yet, vertical-align: top does work. span{ vertical-align: middle; } <div> <img src="https://via.placeholder.com/30" alt="small img" /> ...
sam's user avatar
  • 23.1k
2238 votes
37 answers
3.8m 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 ...
2201 votes
17 answers
1.7m views

HTML 5: Is it <br>, <br/>, or <br />?

I've tried checking other answers, but I'm still confused — especially after seeing W3schools HTML 5 reference. I thought HTML 4.01 was supposed to "allow" single-tags to just be <img> and <...
2098 votes
33 answers
3.7m views

How to auto-resize an image while maintaining aspect ratio

How do you auto-resize a large image so that it will fit into a smaller width div container whilst maintaining its width:height ratio? Example: stackoverflow.com - when an image is inserted onto the ...
001's user avatar
  • 64k
2039 votes
42 answers
2.4m views

How do I make a placeholder for a 'select' box?

I'm using placeholders for text inputs which is working out just fine. But I'd like to use a placeholder for my selectboxes as well. Of course I can just use this code: <select> <option ...
Thomas's user avatar
  • 21.2k
1970 votes
35 answers
3.8m views

How can I set the default value for an HTML <select> element?

I thought that adding a "value" attribute set on the <select> element below would cause the <option> containing my provided "value" to be selected by default: <select name="hall" ...
Jichao's user avatar
  • 41.1k
1923 votes
16 answers
1.4m views

How to move an element into another element

I would like to move one DIV element inside another. For example, I want to move this (including all children): <div id="source"> ... </div> into this: <div id="...
Mark Richman's user avatar
  • 29.3k
1907 votes
21 answers
833k 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 <...
mipadi's user avatar
  • 405k
1895 votes
43 answers
2.8m views

Hide scroll bar, but while still being able to scroll

I want to be able to scroll through the whole page, but without the scrollbar being shown. In Google Chrome it's: ::-webkit-scrollbar { display: none; } But Mozilla Firefox and Internet ...
user_2215528's user avatar
  • 19.3k
1893 votes
9 answers
1.8m views

What does enctype='multipart/form-data' mean?

What does enctype='multipart/form-data' mean in an HTML form and when should we use it?
EBAG's user avatar
  • 22.1k
1892 votes
17 answers
691k views

<button> vs. <input type="button" />. Which to use?

When looking at most sites (including SO), most of them use: <input type="button" /> instead of: <button></button> What are the main differences between the two, if any? Are ...
Aron Rotteveel's user avatar
1889 votes
40 answers
1.2m views

How to align checkboxes and their labels consistently cross-browsers

This is one of the minor CSS problems that plague me constantly. How do folks around Stack Overflow vertically align checkboxes and their labels consistently cross-browser? Whenever I align them ...
1887 votes
10 answers
2.2m views

Vanilla JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for it [duplicate]

With jQuery, we all know the wonderful .ready() function: $('document').ready(function(){}); However, let's say I want to run a function that is written in standard JavaScript with no library ...
chris's user avatar
  • 36.5k
1832 votes
24 answers
3.6m views

How to redirect one HTML page to another on load

Is it possible to set up a basic HTML page to redirect to another page on load?
chobo's user avatar
  • 31.9k
1730 votes
12 answers
1.5m views

What does <meta http-equiv="X-UA-Compatible" content="IE=edge"> do?

What's the difference if one web page starts with <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> and If page starts with <!...
Morgan Cheng's user avatar
  • 74.9k
1726 votes
30 answers
958k views

How Can I add HTML And CSS Into PDF [closed]

I have an HTML (not XHTML) document that renders fine in Firefox 3 and IE 7. It uses fairly basic CSS to style it and renders fine in HTML. I'm now after a way of converting it to PDF. I have tried:...
1663 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> <...
Burak Erdem's user avatar
  • 19.8k
1654 votes
8 answers
1.2m views

<meta charset="utf-8"> vs <meta http-equiv="Content-Type">

In order to define charset for HTML5 Doctype, which notation should I use? Short: <meta charset="utf-8" /> Long: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
CuriousMind's user avatar
  • 33.8k
1649 votes
24 answers
2.0m views

Creating a div element in jQuery [duplicate]

How do I create a div element in jQuery?
useranon's user avatar
  • 29.4k
1645 votes
26 answers
2.2m views

How do I style a <select> dropdown with only CSS?

Is there a CSS-only way to style a <select> dropdown? I need to style a <select> form as much as humanly possible, without any JavaScript. What are the properties I can use to do so in ...
Jitendra Vyas's user avatar
1578 votes
35 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; ...
shinjuo's user avatar
  • 20.8k
1536 votes
15 answers
2.3m views

How can I select an element by name with jQuery?

I have a table column I’m trying to expand and hide. jQuery seems to hide the <td> elements when I select it by class but not by the element’s name. For example: $(".bold").hide(); // ...
T.T.T.'s user avatar
  • 33.9k
1521 votes
12 answers
166k views

Why don't self-closing script elements work?

What is the reason browsers do not correctly recognize: <script src="foobar.js" /> <!-- self-closing script element --> Only this is recognized: <script src="foobar.js"></...
dimarzionist's user avatar
  • 18.6k
1496 votes
27 answers
2.7m views

Check if checkbox is checked with jQuery

How can I check if a checkbox in a checkbox array is checked using the id of the checkbox array? I am using the following code, but it always returns the count of checked checkboxes regardless of id. ...
Jake's user avatar
  • 25.8k

1
2 3 4 5
23747