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 (HyperText Markup Language) is the markup language used for structuring web pages and other information to be displayed in a web browser. HTML describes the structure of a web page semantically along with cues for presentation, making it a markup language rather than a programming language. A browser 'renders' HTML in conjunction with CSS, which defines the 'style' (colours, fonts, layout, etc.), and JavaScript, which defines interactive and dynamic elements, adding style and behaviour to the pages.

https://html.spec.whatwg.org/multipage/ is the canonical HTML specification.


HTML (HyperText Markup Language) is the primary markup language for creating web pages and other information to be displayed to humans in a web browser.

It was invented by Sir Tim Berners-Lee while developing the first Web browser at CERN to enable researchers to share their findings and was formally released in June 1993. The original "HTML Tags" were first publicly mentioned by Berners-Lee in 1991 and borrowed the syntax from CERN's SGML-based documentation standard. The latest and current version for HTML is HTML5.3.

HTML elements form the building blocks of all web pages. HTML allows images and objects to be embedded in a page. It references styles and scripts and carries meta-data. It can be used to create interactive forms. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes, and other items. It can embed scripts written in languages such as JavaScript, which affects the behaviour of HTML web pages. Web pages generated by various programming languages (such as PHP, JSP, VF, ASP.NET, etc.) are rendered as HTML in a browser.

HTML is a hierarchical (tree-structured) markup language. That is, an item might descend from another item, which is its ancestor. However, if item2 is a descendant of item1, they have an additional special relation: item2 is inside of item1, or item1 is wrapped around item2.


Syntax

HTML is written in the form of elements consisting of tags (and their attributes) enclosed in angle brackets (e.g., <html>).

HTML attributes are most commonly expressed in a key="value" format. However, there are exceptions in which some attributes can be written with no value and still be interpreted.

HTML tags most commonly come in pairs. The first is known as the opening tag and the second, which includes a forward slash, is the closing tag (e.g., <h1> and </h1>). Various types of content, such as text or additional HTML elements, can be contained within these tags. Some tags, however, are unpaired, and these are known as empty elements or self-closing tags. They may or may not include the slash (e.g., <img> or <img />).

Collectively, these tags form an HTML document. Web browsers read these documents, interpret each HTML tag, and then render their corresponding visual and/or audible display in the form of a web page.


Standards

HTML standards, as well as those for many other web technologies, are maintained by the World Wide Web Consortium (W3C).

HTML4 was introduced in 1997, and the latest iteration, HTML5, was recently developed by the W3C. What W3C calls HTML5 is a subset, with a few modifications, of the HTML-Living-Standard, which is specified by the Web Hypertext Application Technology Working Group (WHATWG).

The language specification and standards documents for HTML5 are available online.


Design and Scripting

HTML markups are designed, or 'styled', via CSS (Cascading Style Sheets), using one or more of the following:

  • the <link> tag, which loads a CSS file
  • the <style> tag, where CSS rules are defined
  • the style attribute of HTML tags, where inline styles can be specified

Dynamic and interactive parts of a page are programmed most frequently in JavaScript, using one or more of the following:

  • the <script> tag with an src attribute, which points to a script file
  • the <script> opening and closing tags enclosing a script written in JavaScript
  • event attributes of HTML tags, like onclick

FAQ


References:


Free HTML Books:


Related Tags:

HTML5: What’s New?

1180250 questions
2730
votes
37 answers

How do I vertically center text with CSS?

I have a
element which contains text and I want to align the contents of this
vertically center. Here is my
style: #box { height: 170px; width: 270px; background: #000; font-size: 48px; color: #FFF; text-align:…
Irakli Lekishvili
  • 33,492
  • 33
  • 111
  • 169
2696
votes
42 answers

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 height. I want the content div to fill the rest of…
Vincent McNabb
  • 33,327
  • 7
  • 31
  • 53
2647
votes
42 answers

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 now, the background-color ends at the last piece…
mike
  • 26,535
  • 3
  • 16
  • 4
2635
votes
35 answers

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
  • 227,796
  • 193
  • 515
  • 708
2521
votes
29 answers

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 text and the background as two separate elements. When…
Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
2485
votes
43 answers

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

I have a layout similar to:
I would like for the div to only expand to as wide as my table becomes.
George Snider
2418
votes
21 answers

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
  • 25,464
  • 3
  • 23
  • 20
2298
votes
31 answers

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

How can one parse HTML/XML and extract information from it?
RobertPitt
  • 56,863
  • 21
  • 114
  • 161
2275
votes
27 answers

HTML: Valid id attribute values?

When creating the id attributes for HTML elements, what rules are there for the value?
Mr Shark
  • 26,068
  • 5
  • 29
  • 37
2271
votes
14 answers

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. So, only the elements that have both classes. When I use $(".a, .b") it gives me the union, but I want the intersection.
Mladen
  • 25,578
  • 11
  • 39
  • 48
2245
votes
32 answers

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.
monaung
2236
votes
26 answers

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; }
small img Doesn't work.
sam
  • 22,913
  • 3
  • 21
  • 14
2201
votes
18 answers

HTML 5: Is it
,
, or
?

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 and
. Then XHTML came along with and
(where…
ehm
  • 23,789
  • 5
  • 28
  • 31
2060
votes
33 answers

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 editor panel and the image is too large to fit…
001
  • 62,807
  • 94
  • 230
  • 350