HTM by Alphabet
HTM by Alphabet
<base> Specifies the base URL/target for all relative URLs in a document
<bdi> Isolates a part of text that might be formatted in a different direction from other text
outside it
<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)
<col> Specifies column properties for each column within a <colgroup> element
<details> Defines additional details that the user can view or hide
<link> Defines the relationship between a document and an external resource (most used to link
to style sheets)
<noscript> Defines an alternate content for users that do not support client-side scripts
<rp> Defines what to show in browsers that do not support ruby annotations
<source> Defines multiple media resources for media elements (<video> and <audio>)
<template> Defines a container for content that should be hidden when the page loads
<track> Defines text tracks for media elements (<video> and <audio>)
<u> Defines some text that is unarticulated and styled differently from normal text
Basic HTML
Tag Description
Formatting
Tag Description
<bdi> Isolates a part of text that might be formatted in a different direction from other text outside it
<bdo> Overrides the current text direction
<template> Defines a container for content that should be hidden when the page loads
<u> Defines some text that is unarticulated and styled differently from normal text
Frames
Tag Description
Images
Tag Description
<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)
Audio / Video
Tag Description
<source> Defines multiple media resources for media elements (<video>, <audio> and <picture>)
<track> Defines text tracks for media elements (<video> and <audio>)
Links
Tag Description
<a> Defines a hyperlink
<link> Defines the relationship between a document and an external resource (most used to link to style
sheets)
Lists
Tag Description
Tables
Tag Description
<col> Specifies column properties for each column within a <colgroup> element
<details> Defines additional details that the user can view or hide
Meta Info
Tag Description
<base> Specifies the base URL/target for all relative URLs in a document
Programming
Tag Description
<noscript> Defines an alternate content for users that do not support client-side scripts
accept <input> Specifies the types of files that the server accepts (only for
type="file")
accept- <form> Specifies the character encodings that are to be used for
charset the form submission
alt <area>, <img>, <input> Specifies an alternate text when the original element fails
to display
autocomplete <form>, <input> Specifies whether the <form> or the <input> element
should have autocomplete enabled
autofocus <button>, <input>, <select>, <textarea> Specifies that the element should automatically get focus
when the page loads
autoplay <audio>, <video> Specifies that the audio/video will start playing as soon as
it is ready
bgcolor Not supported in HTML 5. Specifies the background color of an element. Use CSS
instead
border Not supported in HTML 5. Specifies the width of the border of an element. Use CSS
instead
cite <blockquote>, <del>, <ins>, <q> Specifies a URL which explains the quote/deleted/inserted
text
class Global Attributes Specifies one or more classnames for an element (refers to
a class in a style sheet)
color Not supported in HTML 5. Specifies the text color of an element. Use CSS instead
colspan <td>, <th> Specifies the number of columns a table cell should span
content <meta> Gives the value associated with the http-equiv or name
attribute
data <object> Specifies the URL of the resource to be used by the object
data-* Global Attributes Used to store custom data private to the page or
application
datetime <del>, <ins>, <time> Specifies the date and time
defer <script> Specifies that the script is executed when the page has
finished parsing (only for external scripts)
dir Global Attributes Specifies the text direction for the content in an element
dirname <input>, <textarea> Specifies that the text direction will be submitted
disabled <button>, <fieldset>, <input>, Specifies that the specified element/group of elements
<optgroup>, <option>, <select>, <textarea> should be disabled
download <a>, <area> Specifies that the target will be downloaded when a user
clicks on the hyperlink
form <button>, <fieldset>, <input>, Specifies the name of the form the element belongs to
<label>, <meter>, <object>, <output>, <select>, <textar
ea>
formaction <button>, <input> Specifies where to send the form-data when a form is
submitted. Only for type="submit"
headers <td>, <th> Specifies one or more headers cells a cell is related to
height <canvas>, <embed>, <iframe>, <img>, <input>, <object> Specifies the height of the element
, <video>
href <a>, <area>, <base>, <link> Specifies the URL of the page the link goes to
hreflang <a>, <area>, <link> Specifies the language of the linked document
label <track>, <option>, <optgroup> Specifies the title of the text track
loop <audio>, <video> Specifies that the audio/video will start over again, every
time it is finished
method <form> Specifies the HTTP method to use when sending form-data
multiple <input>, <select> Specifies that a user can enter more than one value
muted <video>, <audio> Specifies that the audio output of the video should be
muted
name <button>, <fieldset>, <form>, <iframe>, <input>, <map> Specifies the name of the element
, <meta>, <object>, <output>, <param>, <select>, <texta
rea>
novalidate <form> Specifies that the form should not be validated when
submitted
onblur All visible elements. Script to be run when the element loses focus
oncanplay <audio>, <embed>, <object>, <video> Script to be run when a file is ready to start playing (when
it has buffered enough to begin)
oncanplaythr <audio>, <video> Script to be run when a file can be played all the way to the
ough end without pausing for buffering
onchange All visible elements. Script to be run when the value of the element is changed
onclick All visible elements. Script to be run when the element is being clicked
oncontextme All visible elements. Script to be run when a context menu is triggered
nu
oncopy All visible elements. Script to be run when the content of the element is being
copied
oncut All visible elements. Script to be run when the content of the element is being
cut
ondblclick All visible elements. Script to be run when the element is being double-clicked
ondrag All visible elements. Script to be run when the element is being dragged
ondragend All visible elements. Script to be run at the end of a drag operation
ondragenter All visible elements. Script to be run when an element has been dragged to a
valid drop target
ondragleave All visible elements. Script to be run when an element leaves a valid drop target
ondragover All visible elements. Script to be run when an element is being dragged over a
valid drop target
ondragstart All visible elements. Script to be run at the start of a drag operation
ondrop All visible elements. Script to be run when dragged element is being dropped
ondurationch <audio>, <video> Script to be run when the length of the media changes
ange
onemptied <audio>, <video> Script to be run when something bad happens and the file
is suddenly unavailable (like unexpectedly disconnects)
onended <audio>, <video> Script to be run when the media has reach the end (a
useful event for messages like "thanks for listening")
onerror <audio>, <body>, <embed>, <img>, <object>, <script>, < Script to be run when an error occurs
style>, <video>
onfocus All visible elements. Script to be run when the element gets focus
onhashchang <body> Script to be run when there has been changes to the
e anchor part of the a URL
oninput All visible elements. Script to be run when the element gets user input
oninvalid All visible elements. Script to be run when the element is invalid
onkeydown All visible elements. Script to be run when a user is pressing a key
onkeypress All visible elements. Script to be run when a user presses a key
onkeyup All visible elements. Script to be run when a user releases a key
onload <body>, <iframe>, <img>, <input>, <link>, <script>, <styl Script to be run when the element is finished loading
e>
onloadedmet <audio>, <video> Script to be run when meta data (like dimensions and
adata duration) are loaded
onloadstart <audio>, <video> Script to be run just as the file begins to load before
anything is actually loaded
onmousedow All visible elements. Script to be run when a mouse button is pressed down on
n an element
onmousemov All visible elements. Script to be run as long as the mouse pointer is moving
e over an element
onmouseout All visible elements. Script to be run when a mouse pointer moves out of an
element
onmouseover All visible elements. Script to be run when a mouse pointer moves over an
element
onmouseup All visible elements. Script to be run when a mouse button is released over an
element
onmousewhe All visible elements. Script to be run when a mouse wheel is being scrolled over
el an element
onoffline <body> Script to be run when the browser starts to work offline
ononline <body> Script to be run when the browser starts to work online
onpagehide <body> Script to be run when a user navigates away from a page
onpaste All visible elements. Script to be run when the user pastes some content in an
element
onpause <audio>, <video> Script to be run when the media is paused either by the
user or programmatically
onplay <audio>, <video> Script to be run when the media has started playing
onplaying <audio>, <video> Script to be run when the media has started playing
onprogress <audio>, <video> Script to be run when the browser is in the process of
getting the media data
onratechange <audio>, <video> Script to be run each time the playback rate changes (like
when a user switches to a slow motion or fast forward
mode).
onresize <body> Script to be run when the browser window is being resized.
onscroll All visible elements. Script to be run when an element's scrollbar is being
scrolled
onseeked <audio>, <video> Script to be run when the seeking attribute is set to false
indicating that seeking has ended
onseeking <audio>, <video> Script to be run when the seeking attribute is set to true
indicating that seeking is active
onselect All visible elements. Script to be run when the element gets selected
onstalled <audio>, <video> Script to be run when the browser is unable to fetch the
media data for whatever reason
onsuspend <audio>, <video> Script to be run when fetching the media data is stopped
before it is completely loaded for whatever reason
ontimeupdat <audio>, <video> Script to be run when the playing position has changed
e (like when the user fast forwards to a different point in the
media)
ontoggle <details> Script to be run when the user opens or closes the
<details> element
onunload <body> Script to be run when a page has unloaded (or the browser
window has been closed)
onvolumecha <audio>, <video> Script to be run each time the volume of a video/audio has
nge been changed
onwaiting <audio>, <video> Script to be run when the media has paused but is
expected to resume (like when the media pauses to buffer
more data)
onwheel All visible elements. Script to be run when the mouse wheel rolls up or down
over an element
open <details> Specifies that the details should be visible (open) to the
user
optimum <meter> Specifies what value is the optimal value for the gauge
placeholder <input>, <textarea> Specifies a short hint that describes the expected value of
the element
preload <audio>, <video> Specifies if and how the author thinks the audio/video
should be loaded when the page loads
rel <a>, <area>, <form>, <link> Specifies the relationship between the current document
and the linked document
required <input>, <select>, <textarea> Specifies that the element must be filled out before
submitting the form
reversed <ol> Specifies that the list order should be descending (9,8,7...)
rowspan <td>, <th> Specifies the number of rows a table cell should span
size <input>, <select> Specifies the width, in characters (for <input>) or specifies
the number of visible options (for <select>)
sizes <img>, <link>, <source> Specifies the size of the linked resource
spellcheck Global Attributes Specifies whether the element is to have its spelling and
grammar checked or not
src <audio>, <embed>, <iframe>, <img>, <input>, <script>, Specifies the URL of the media file
<source>, <track>, <video>
srcdoc <iframe> Specifies the HTML content of the page to show in the
<iframe>
srclang <track> Specifies the language of the track text data (required if
kind="subtitles")
srcset <img>, <source> Specifies the URL of the image to use in different situations
step <input> Specifies the legal number intervals for an input field
target <a>, <area>, <base>, <form> Specifies the target for where to open the linked document
or where to submit the form
type <a>, <button>, <embed>, <input>, <link>, <menu>, <obj Specifies the type of element
ect>, <script>, <source>, <style>
value <button>, <input>, <li>, <option>, <meter>, <progress>, Specifies the value of the element
<param>
width <canvas>, <embed>, <iframe>, <img>, <input>, <object> Specifies the width of the element
, <video>
wrap <textarea> Specifies how the text in a text area is to be wrapped when
submitted in a form
The global attributes are attributes that can be used with all HTML elements.
Attribute Description
accesskey Specifies a shortcut key to activate/focus an element
class Specifies one or more classnames for an element (refers to a class in a style sheet)
spellcheck Specifies whether the element is to have its spelling and grammar checked or not
To learn more about programming events, please visit our JavaScript tutorial.
Below are the global event attributes that can be added to HTML elements to define event actions.
Window Event Attributes
Events triggered for the window object (applies to the <body> tag):
onhashchange script Script to be run when there has been changes to the anchor part of the a URL
onoffline script Script to be run when the browser starts to work offline
ononline script Script to be run when the browser starts to work online
Onpagehide script Script to be run when a user navigates away from a page
Form Events
Events triggered by actions inside a HTML form (applies to almost all HTML elements, but is most used in form
elements):
onblur script Fires the moment that the element loses focus
onchange script Fires the moment when the value of the element is changed
onfocus script Fires the moment when the element gets focus
onsearch script Fires when the user writes something in a search field (for <input="search">)
onselect script Fires after some text has been selected in an element
Keyboard Events
Attribute Value Description
Mouse Events
Attribute Value Description
onmousemove script Fires when the mouse pointer is moving while it is over an element
onmouseout script Fires when the mouse pointer moves out of an element
onmouseover script Fires when the mouse pointer moves over an element
onwheel script Fires when the mouse wheel rolls up or down over an element
Drag Events
Attribute Value Description
ondragenter script Script to be run when an element has been dragged to a valid drop target
ondragleave script Script to be run when an element leaves a valid drop target
ondragover script Script to be run when an element is being dragged over a valid drop target
Clipboard Events
Attribute Value Description
oncopy script Fires when the user copies the content of an element
oncut script Fires when the user cuts the content of an element
onpaste script Fires when the user pastes some content in an element
Media Events
Events triggered by medias like videos, images and audio (applies to all HTML elements, but is most common in media elements, like
<audio>, <embed>, <img>, <object>, and <video>).
Tip: Look at our HTML Audio and Video DOM Reference for more information.
Attribute Value Description
Oncanplaythrough script Script to be run when a file can be played all the way to the end without pausing for
buffering
Oncuechange script Script to be run when the cue changes in a <track> element
Ondurationchange script Script to be run when the length of the media changes
Onemptied script Script to be run when something bad happens and the file is suddenly unavailable (like
unexpectedly disconnects)
Onended script Script to be run when the media has reach the end (a useful event for messages like
"thanks for listening")
Onerror script Script to be run when an error occurs when the file is being loaded
Onloadedmetadata script Script to be run when meta data (like dimensions and duration) are loaded
Onloadstart script Script to be run just as the file begins to load before anything is actually loaded
Onpause script Script to be run when the media is paused either by the user or programmatically
Onplay script Script to be run when the media is ready to start playing
Onplaying script Script to be run when the media actually has started playing
Onprogress script Script to be run when the browser is in the process of getting the media data
Onratechange script Script to be run each time the playback rate changes (like when a user switches to a slow
motion or fast forward mode)
Onseeked script Script to be run when the seeking attribute is set to false indicating that seeking has ended
Onseeking script Script to be run when the seeking attribute is set to true indicating that seeking is active
Onstalled script Script to be run when the browser is unable to fetch the media data for whatever reason
Onsuspend script Script to be run when fetching the media data is stopped before it is completely loaded for
whatever reason
Ontimeupdate script Script to be run when the playing position has changed (like when the user fast forwards
to a different point in the media)
Onvolumechange script Script to be run each time the volume is changed which (includes setting the volume to
"mute")
Onwaiting script Script to be run when the media has paused but is expected to resume (like when the
media pauses to buffer more data)
Misc Events
Attribute Value Description
ontoggle script Fires when the user opens or closes the <details> element
The Canvas API can draw shapes, lines, curves, boxes, text, and images, with colors, rotations, transparencies,
and other pixel manipulations.
You can add a canvas element anywhere in an HTML page with the <canvas> tag:
Example
<canvas id="myCanvas" width="300" height="150"></canvas>
Try it Yourself »
You can access a <canvas> element with the HTML DOM method getElementById().
Note
The HTML <canvas> element itself has no drawing abilities.
The getContext() method returns an object with tools (methods) for drawing.
The fillRect() method draws a black rectangle with a top-left corner at position 20,20. The rectangle is 150
pixel wide and 100 pixels high.
Example
const myCanvas = document.getElementById("myCanvas");
const ctx = myCanvas.getContext("2d");
ctx.fillRect(20, 20, 150, 100);
Try it Yourself »
Using Colors
The fillStyle property sets the fill color of the drawing object:
Example
const myCanvas = document.getElementById("myCanvas");
const ctx = myCanvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 150, 100);
Try it Yourself »
You can also create a new <canvas> element with the document.createElement() method, and add the
element to an existing HTML page:
Example
const myCanvas = document.createElement("canvas");
document.body.appendChild(myCanvas);
const ctx = myCanvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(20, 20, 150, 100);
Try it Yourself »
Paths
The common way to draw on the canvas is to:
Example
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(20, 100);
ctx.lineTo(70, 100);
ctx.stroke();
Try it Yourself »
Path Methods
Method Description
closePath() Adds a line to the path from the current point to the start
Text
Method/Prop Description
measureText() Returns an object that contains the width of the specified text
textBaseline Sets or returns the text baseline used when drawing text
lineCap Sets or returns the style of the end caps for a line
lineJoin Sets or returns the type of corner created, when two lines meet
shadowOffsetX Sets or returns the horizontal distance of the shadow from the shape
shadowOffsetY Sets or returns the vertical distance of the shadow from the shape
strokeStyle Sets or returns the color, gradient, or pattern used for strokes
Transformations
Method Description
setTransform() Resets the current transform to the identity matrix. Then runs transform()
Image Drawing
Method Description
getImageData() Returns an ImageData object that copies the pixel data for the specified rectangle on a canvas
ImageData.data Returns an object that contains image data of a specified ImageData object
putImageData() Puts the image data (from a specified ImageData object) back onto the canvas
Compositing
Property Description
globalAlpha Sets or returns the current alpha or transparency value of the drawing
globalCompositeOperation Sets or returns how a new image are drawn onto an existing image
Other Methods
Method Description
clip() Clips a region of any shape and size from the original canvas
save() Saves the state of the current drawing context and all its atributes
createEvent()
getContext()
toDataURL()
Related Pages
HTML tutorial: HTML5 Canvas
HTML reference: HTML <canvas> tag
Browser Support
The <canvas> element is an HTML5 standard (2014).
Canvas API is supported in all modern browsers:
canPlayType() Checks if the browser can play the specified audio/video type
autoplay Sets or returns whether the audio/video should start playing as soon as it is loaded
buffered Returns a TimeRanges object representing the buffered parts of the audio/video
controller Returns the MediaController object representing the current media controller of the
audio/video
controls Sets or returns whether the audio/video should display controls (like play/pause etc.)
currentTime Sets or returns the current playback position in the audio/video (in seconds)
ended Returns whether the playback of the audio/video has ended or not
error Returns a MediaError object representing the error state of the audio/video
loop Sets or returns whether the audio/video should start over again when finished
mediaGroup Sets or returns the group the audio/video belongs to (used to link multiple audio/video
elements)
played Returns a TimeRanges object representing the played parts of the audio/video
preload Sets or returns whether the audio/video should be loaded when the page loads
seekable Returns a TimeRanges object representing the seekable parts of the audio/video
canplay Fires when the browser can start playing the audio/video
canplaythrough Fires when the browser can play through the audio/video without stopping for buffering
loadeddata Fires when the browser has loaded the current frame of the audio/video
loadedmetadata Fires when the browser has loaded meta data for the audio/video
loadstart Fires when the browser starts looking for the audio/video
play Fires when the audio/video has been started or is no longer paused
playing Fires when the audio/video is playing after having been paused or stopped for buffering
seeked Fires when the user is finished moving/skipping to a new position in the audio/video
seeking Fires when the user starts moving/skipping to a new position in the audio/video
stalled Fires when the browser is trying to get media data, but data is not available
suspend Fires when the browser is intentionally not getting media data
waiting Fires when the video stops because it needs to buffer the next frame
32 space
33 ! ! ! ! exclamation mark
35 # # # # number sign
36 $ $ $ $ dollar sign
37 % % % % percent sign
40 ( ( ( ( left parenthesis
41 ) ) ) ) right parenthesis
42 * * * * Asterisk
43 + + + + plus sign
44 , , , , Comma
45 - - - - hyphen-minus
46 . . . . full stop
47 / / / / Solidus
48 0 0 0 0 digit zero
49 1 1 1 1 digit one
50 2 2 2 2 digit two
51 3 3 3 3 digit three
52 4 4 4 4 digit four
53 5 5 5 5 digit five
54 6 6 6 6 digit six
55 7 7 7 7 digit seven
56 8 8 8 8 digit eight
57 9 9 9 9 digit nine
58 : : : : Colon
59 ; ; ; ; Semicolon
60 < < < < less-than sign
61 = = = = equals sign
63 ? ? ? ? question mark
64 @ @ @ @ commercial at
92 \ \ \ \ reverse solidus
94 ^ ^ ^ ^ circumflex accent
95 _ _ _ _ low line
96 ` ` ` ` grave accent
126 ~ ~ ~ ~ Tilde
127 DEL
134 † Dagger
149 • Bullet
150 – en dash
151 — em dash
168 ¨ ¨ ¨ Diaeresis
175 ¯ ¯ ¯ Macron
184 ¸ ¸ ¸ Cedilla
1xx: Information
Message: Description:
100 Continue The server has received the request headers, and the client should proceed to send the
request body
101 Switching Protocols The requester has asked the server to switch protocols
103 Early Hints Used with the Link header to allow the browser to start preloading resources while the
server prepares a response
2xx: Successful
Message: Description:
200 OK The request is OK (this is the standard response for successful HTTP requests)
201 Created The request has been fulfilled, and a new resource is created
202 Accepted The request has been accepted for processing, but the processing has not
been completed
203 Non-Authoritative Information The request has been successfully processed, but is returning information
that may be from another source
204 No Content The request has been successfully processed, but is not returning any content
205 Reset Content The request has been successfully processed, but is not returning any
content, and requires that the requester reset the document view
206 Partial Content The server is delivering only part of the resource due to a range header sent
by the client
3xx: Redirection
Message: Description:
300 Multiple Choices A link list. The user can select a link and go to that location. Maximum five
addresses
301 Moved Permanently The requested page has moved to a new URL
302 Found The requested page has moved temporarily to a new URL
303 See Other The requested page can be found under a different URL
304 Not Modified Indicates the requested page has not been modified since last requested
307 Temporary Redirect The requested page has moved temporarily to a new URL
308 Permanent Redirect The requested page has moved permanently to a new URL
400 Bad Request The request cannot be fulfilled due to bad syntax
401 Unauthorized The request was a legal request, but the server is refusing to respond to it.
For use when authentication is possible but has failed or not yet been
provided
403 Forbidden The request was a legal request, but the server is refusing to respond to it
404 Not Found The requested page could not be found but may be available again in the
future
405 Method Not Allowed A request was made of a page using a request method not supported by that
page
406 Not Acceptable The server can only generate a response that is not accepted by the client
407 Proxy Authentication Required The client must first authenticate itself with the proxy
408 Request Timeout The server timed out waiting for the request
409 Conflict The request could not be completed because of a conflict in the request
412 Precondition Failed The precondition given in the request evaluated to false by the server
413 Request Too Large The server will not accept the request, because the request entity is too large
414 Request-URI Too Long The server will not accept the request, because the URI is too long. Occurs
when you convert a POST request to a GET request with a long query
information
415 Unsupported Media Type The server will not accept the request, because the media type is not
supported
416 Range Not Satisfiable The client has asked for a portion of the file, but the server cannot supply that
portion
417 Expectation Failed The server cannot meet the requirements of the Expect request-header field
500 Internal Server Error A generic error message, given when no more specific message is suitable
501 Not Implemented The server either does not recognize the request method, or it lacks the
ability to fulfill the request
502 Bad Gateway The server was acting as a gateway or proxy and received an invalid response
from the upstream server
504 Gateway Timeout The server was acting as a gateway or proxy and did not receive a timely
response from the upstream server
505 HTTP Version Not Supported The server does not support the HTTP protocol version used in the request
511 Network Authentication Required The client needs to authenticate to gain network access
What is HTTP?
The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.
HTTP works as a request-response protocol between a client and server.
Example: A client (browser) sends an HTTP request to the server; then the server returns a response to the client. The response contains
status information about the request and may also contain the requested content.
HTTP Methods
GET
POST
PUT
HEAD
DELETE
PATCH
OPTIONS
CONNECT
TRACE
The two most common HTTP methods are: GET and POST.
name1=value1&name2=value2
Some notes on POST requests:
POST requests are never cached
POST requests do not remain in the browser history
POST requests cannot be bookmarked
POST requests have no restrictions on data length
History Parameters remain in browser history Parameters are not saved in browser
history
Restrictions on data length Yes, when sending data, the GET method adds the data to No restrictions
the URL; and the length of a URL is limited (maximum URL
length is 2048 characters)
Restrictions on data type Only ASCII characters allowed No restrictions. Binary data is also allowed
Security GET is less secure compared to POST because data sent is POST is a little safer than GET because the
part of the URL parameters are not stored in browser
history or in web server logs
Never use GET when sending passwords or other sensitive
information!
Visibility Data is visible to everyone in the URL Data is not displayed in the URL
Pixel to Em Converter
The tool below allows you to work out the em sizes from pixels (or vice versa).
Set a default pixel size for body (usually 16px)
Then, convert a pixel value to em, based on the default pixel size
Or, convert an em value to pixels, based on the default pixel size
Set a default pixel size: 16px
px
800px
Convert PX to EM:
px
Convert EM to PX:
em
Convert
Result: 50em
Body Font Size
In the table below, select a body font size in pixels (px) to display a complete "px to em and percent" conversion table.
Tip: The default font size is usually 16px.
Px em percent
Basic Shortcuts
Description Windows Mac OS
Text Editing
Description Windows Mac OS
Cursor Movement
Go to the right or to the beginning of next line break Right Arrow Right Arrow
Go to the left or to the end of previous line break Left Arrow Left Arrow
Text Selection
Select characters to the left Shift + Left Arrow Shift + Left Arrow
Select characters to the right Shift + Right Arrow Shift + Right Arrow
Select words to the left Shift + Ctrl + Left Shift + Opt + Left
Select words to the right Shift + Ctrl + Right Shift + Opt + Right
Select paragraphs to the right Shift + Ctrl + Down Shift + Opt + Down
Select text between the cursor and the beginning of Shift + Home Cmd + Shift + Left Arrow
the current line
Select text between the cursor and the end of the Shift + End Cmd + Shift + Right Arrow
current line
Select text between the cursor and the beginning of Shift + Ctrl + Home Cmd + Shift + Up Arrow or Cmd + Shift + Fn +
the document Left Arrow
Select text between the cursor and the end of the Shift + Ctrl + End Cmd + Shift + Down Arrow or Cmd + Shift + Fn +
document Right Arrow
Select one frame at a time of text above the cursor Shift + Page Up Shift + Fn + Up Arrow
Select one frame at a time of text below the cursor Shift + Page Down Shift + Fn + Down Arrow
Text Formatting
Text Editing
Web Browsers
Description Windows Mac OS
Navigation
Close all tabs except the current tab Ctrl + Alt + F4 Cmd + Opt + W
Open links in a new tab in the background Ctrl + Click Cmd + Click
Open links in a new tab in the foreground Ctrl + Shift + Click Cmd + Shift + Click
Address Bar
Cycle between toolbar, search bar, and page elements Tab Tab
Focus and select the browser's search bar Ctrl + E Cmd + E / Cmd + K
Open the address bar location in a new tab Alt + Enter Opt + Enter
Add "www." to the beginning and ".com" to the end of the text typed in the Ctrl + Enter Cmd + Enter or Control
address bar (e.g., type "w3schools" and press Ctrl + Enter to open + Enter
"www.w3schools.com")
Bookmarks
Screenshots
Description Windows Mac OS
Copy screenshot of the whole screen to the clipboard PrtScr (Print Screen) or Ctrl + Cmd + Ctrl + Shift + 3
PrtScr
Copy screenshot of window to the clipboard Alt + PrtScr Cmd + Ctrl + Shift + 4, then
Space
align-content Specifies the alignment between the lines inside a flexible container when the items do not
use all available space
align-self Specifies the alignment for selected items inside a flexible container
animation-direction Specifies whether an animation should be played forwards, backwards or in alternate cycles
animation-duration Specifies how long an animation should take to complete one cycle
animation-fill-mode Specifies a style for the element when the animation is not playing (before it starts, after it
ends, or both)
B
backdrop-filter Defines a graphical effect to the area behind an element
backface-visibility Defines whether or not the back face of an element should be visible when facing the user
background-attachment Sets whether a background image scrolls with the rest of the page, or is fixed
background-clip Defines how far the background (color or image) should extend within an element
border-block-color Sets the color of the borders at start and end in the block direction
border-block-end-color Sets the color of the border at the end in the block direction
border-block-end-style Sets the style of the border at the end in the block direction
border-block-end-width Sets the width of the border at the end in the block direction
border-block-start-color Sets the color of the border at the start in the block direction
border-block-start-style Sets the style of the border at the start in the block direction
border-block-start-width Sets the width of the border at the start in the block direction
border-block-style Sets the style of the borders at start and end in the block direction
border-block-width Sets the width of the borders at start and end in the block direction
border-collapse Sets whether table borders should collapse into a single border or be separated
border-end-end-radius Sets the radius of the corner between the block-end and the inline-end sides of the
element
border-end-start-radius Sets the radius of the corner between the block-end and the inline-start sides of the
element
border-image-outset Specifies the amount by which the border image area extends beyond the border box
border-image-repeat Specifies whether the border image should be repeated, rounded or stretched
border-inline-end-color Sets the color of the border at the end in the inline direction
border-inline-end-style Sets the style of the border at the end in the inline direction
border-inline-end-width Sets the width of the border at the end in the inline direction
border-inline-start-color Sets the color of the border at the start in the inline direction
border-inline-start-style Sets the style of the border at the start in the inline direction
border-inline-start-width Sets the width of the border at the start in the inline direction
border-inline-style Sets the style of the borders at start and end in the inline direction
border-inline-width Sets the width of the borders at start and end in the inline direction
border-start-end-radius Sets the radius of the corner between the block-start and the inline-end sides of the
element
border-start-start-radius Sets the radius of the corner between the block-start and the inline-start sides of the
element
bottom Sets the elements position, from the bottom of its parent element
box-decoration-break Sets the behavior of the background and border of an element at page-break, or, for in-line
elements, at line-break.
box-sizing Defines how the width and height of an element are calculated: should they include
padding and borders, or not
break-after Specifies whether or not a page-, column-, or region-break should occur after the specified
element
break-before Specifies whether or not a page-, column-, or region-break should occur before the
specified element
break-inside Specifies whether or not a page-, column-, or region-break should occur inside the specified
element
C
caption-side Specifies the placement of a table caption
caret-color Specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable
clear Specifies what should happen with the element that is next to a floating element
content Used with the :before and :after pseudo-elements, to insert generated content
counter-increment Increases or decreases the value of one or more CSS counters
cursor Specifies the mouse cursor to be displayed when pointing over an element
D
direction Specifies the text direction/writing direction
E
empty-cells Specifies whether or not to display borders and background on empty cells in a table
F
filter Defines effects (e.g. blurring or color shifting) on an element before the element is displayed
flex A shorthand property for the flex-grow, flex-shrink, and the flex-basis properties
flex-flow A shorthand property for the flex-direction and the flex-wrap properties
flex-grow Specifies how much the item will grow relative to the rest
flex-shrink Specifies how the item will shrink relative to the rest
float Specifies whether an element should float to the left, right, or not at all
font A shorthand property for the font-style, font-variant, font-weight, font-size/line-height, and the font-
family properties
@font-face A rule that allows websites to download and use fonts other than the "web-safe" fonts
@font-feature-values Allows authors to use a common name in font-variant-alternate for feature activated differently in
OpenType
font-kerning Controls the usage of the kerning information (how letters are spaced)
font-synthesis Controls which missing typefaces (bold or italic) may be synthesized by the browser
font-variant-alternates Controls the usage of alternate glyphs associated to alternative names defined in @font-feature-values
font-variant-east-asian Controls the usage of alternate glyphs for East Asian scripts (e.g Japanese and Chinese)
font-variant-ligatures Controls which ligatures and contextual forms are used in textual content of the elements it applies to
font-variant-numeric Controls the usage of alternate glyphs for numbers, fractions, and ordinal markers
font-variant-position Controls the usage of alternate glyphs of smaller size positioned as superscript or subscript regarding the
baseline of the font
G
gap A shorthand property for the row-gap and the column-gap properties
grid-area Either specifies a name for the grid item, or this property is a shorthand property for the grid-row-
start, grid-column-start, grid-row-end, and grid-column-end properties
grid-column A shorthand property for the grid-column-start and the grid-column-end properties
grid-row A shorthand property for the grid-row-start and the grid-row-end properties
grid-template-areas Specifies how to display columns and rows, using named grid items
grid-template-columns Specifies the size of the columns, and how many columns in a grid layout
H
hanging-punctuation Specifies whether a punctuation character may be placed outside the line box
I
image-rendering Specifies the type of algorithm to use for image scaling
@import Allows you to import a style sheet into another style sheet
inset Specifies the distance between an element and the parent element
inset-block Specifies the distance between an element and the parent element in the block direction
inset-block-end Specifies the distance between the end of an element and the parent element in the block
direction
inset-block-start Specifies the distance between the start of an element and the parent element in the block
direction
inset-inline Specifies the distance between an element and the parent element in the inline direction
inset-inline-end Specifies the distance between the end of an element and the parent element in the inline
direction
inset-inline-start Specifies the distance between the start of an element and the parent element in the inline
direction
J
justify-content Specifies the alignment between the items inside a flexible container when the items do not use all
available space
justify-items Is set on the grid container. Specifies the alignment of grid items in the inline direction
justify-self Is set on the grid item. Specifies the alignment of the grid item in the inline direction
K
@keyframes Specifies the animation code
L
left Specifies the left position of a positioned element
M
margin Sets all the margin properties in one declaration
mask-composite Represents a compositing operation used on the current mask layer with the mask layers below it
mask-mode Specifies whether the mask layer image is treated as a luminance mask or as an alpha mask
mask-origin Specifies the origin position (the mask position area) of a mask layer image
mask-position Sets the starting position of a mask layer image (relative to the mask position area)
mix-blend-mode Specifies how an element's content should blend with its direct parent background
O
object-fit Specifies how the contents of a replaced element should be fitted to the box established by its used
height and width
object-position Specifies the alignment of the replaced element inside its box
offset-anchor Specifies a point on an element that is fixed to the path it is animated along
offset-distance Specifies the position along a path where an animated element is placed
order Sets the order of the flexible item, relative to the rest
orphans Sets the minimum number of lines that must be left at the bottom of a page or column
outline A shorthand property for the outline-width, outline-style, and the outline-color properties
overflow-anchor Specifies whether or not content in viewable area in a scrollable contianer should be pushed down when
new content is loaded above
overflow-wrap Specifies whether or not the browser can break lines with long words, if they overflow the container
overflow-x Specifies whether or not to clip the left/right edges of the content, if it overflows the element's content
area
overflow-y Specifies whether or not to clip the top/bottom edges of the content, if it overflows the element's
content area
overscroll-behavior Specifies whether to have scroll chaining or overscroll affordance in x- and y-directions
overscroll-behavior- Specifies whether to have scroll chaining or overscroll affordance in the block direction
block
overscroll-behavior- Specifies whether to have scroll chaining or overscroll affordance in the inline direction
inline
P
padding A shorthand property for all the padding-* properties
perspective-origin Defines at which position the user is looking at the 3D-positioned element
place-content Specifies align-content and justify-content property values for flexbox and grid layouts
place-items Specifies align-items and justify-items property values for grid layouts
place-self Specifies align-self and justify-self property values for grid layouts
position Specifies the type of positioning method used for an element (static, relative, absolute or fixed)
Q
quotes Sets the type of quotation marks for embedded quotations
R
resize Defines if (and how) an element is resizable by the user
S
scale Specifies the size of an element by scaling up or down
scroll-behavior Specifies whether to smoothly animate the scroll position in a scrollable box, instead of a
straight jump
scroll-margin Specifies the margin between the snap position and the container
scroll-margin-block Specifies the margin between the snap position and the container in the block direction
scroll-margin-block-end Specifies the end margin between the snap position and the container in the block
direction
scroll-margin-block-start Specifies the start margin between the snap position and the container in the block
direction
scroll-margin-bottom Specifies the margin between the snap position on the bottom side and the container
scroll-margin-inline Specifies the margin between the snap position and the container in the inline direction
scroll-margin-inline-end Specifies the end margin between the snap position and the container in the inline
direction
scroll-margin-inline-start Specifies the start margin between the snap position and the container in the inline
direction
scroll-margin-left Specifies the margin between the snap position on the left side and the container
scroll-margin-right Specifies the margin between the snap position on the right side and the container
scroll-margin-top Specifies the margin between the snap position on the top side and the container
scroll-padding Specifies the distance from the container to the snap position on the child elements
scroll-padding-block Specifies the distance in block direction from the container to the snap position on the child
elements
scroll-padding-block-end Specifies the distance in block direction from the end of the container to the snap position
on the child elements
scroll-padding-block-start Specifies the distance in block direction from the start of the container to the snap position
on the child elements
scroll-padding-bottom Specifies the distance from the bottom of the container to the snap position on the child
elements
scroll-padding-inline Specifies the distance in inline direction from the container to the snap position on the
child elements
scroll-padding-inline-end Specifies the distance in inline direction from the end of the container to the snap position
on the child elements
scroll-padding-inline-start Specifies the distance in inline direction from the start of the container to the snap position
on the child elements
scroll-padding-left Specifies the distance from the left side of the container to the snap position on the child
elements
scroll-padding-right Specifies the distance from the right side of the container to the snap position on the child
elements
scroll-padding-top Specifies the distance from the top of the container to the snap position on the child
elements
scroll-snap-align Specifies where to position elements when the user stops scrolling
scroll-snap-stop Specifies scroll behaviour after fast swipe on trackpad or touch screen
T
tab-size Specifies the width of a tab character
table-layout Defines the algorithm used to lay out table cells, rows, and columns
text-align-last Describes how the last line of a block or a line right before a forced line break is aligned
when text-align is "justify"
text-combine-upright Specifies the combination of multiple characters into the space of a single character
text-overflow Specifies what should happen when text overflows the containing element
text-underline-position Specifies the position of the underline which is set using the text-decoration property
transition-duration Specifies how many seconds or milliseconds a transition effect takes to complete
transition-property Specifies the name of the CSS property the transition effect is for
V
vertical-align Sets the vertical alignment of an element
W
white-space Specifies how white-space inside an element is handled
widows Sets the minimum number of lines that must be left at the top of a page or column
word-break Specifies how words should break when reaching the end of a line
word-wrap Allows long, unbreakable words to be broken and wrap to the next line
writing-mode Specifies whether lines of text are laid out horizontally or vertically
Z
z-index Sets the stack order of a positioned element
CSS Selectors
In CSS, selectors are patterns used to select the element(s) you want to style.
Use our CSS Selector Tester to demonstrate the different selectors.
Selector Example Example description
.class1.class2 .name1.name2 Selects all elements with both name1 and name2 set within its class attribute
.class1 .class2 .name1 .name2 Selects all elements with name2 that is a descendant of an element
with name1
element,element div, p Selects all <div> elements and all <p> elements
element element div p Selects all <p> elements inside <div> elements
element>element div > p Selects all <p> elements where the parent is a <div> element
element+element div + p Selects the first <p> element that is placed immediately after <div> elements
[attribute~=value] [title~="flower"] Selects all elements with a title attribute containing the word "flower"
[attribute|=value] [lang|="en"] Selects all elements with a lang attribute value equal to "en" or starting with
"en-"
[attribute^=value] a[href^="https"] Selects every <a> element whose href attribute value begins with "https"
[attribute$=value] a[href$=".pdf"] Selects every <a> element whose href attribute value ends with ".pdf"
[attribute*=value] a[href*="w3schools"] Selects every <a> element whose href attribute value contains the substring
"w3schools"
::after p::after Insert something after the content of each <p> element
::before p::before Insert something before the content of each <p> element
:empty p:empty Selects every <p> element that has no children (including text nodes)
:first-child p:first-child Selects every <p> element that is the first child of its parent
:first-of-type p:first-of-type Selects every <p> element that is the first <p> element of its parent
:in-range input:in-range Selects input elements with a value within a specified range
:last-child p:last-child Selects every <p> element that is the last child of its parent
:last-of-type p:last-of-type Selects every <p> element that is the last <p> element of its parent
:nth-child(n) p:nth-child(2) Selects every <p> element that is the second child of its parent
:nth-last-child(n) p:nth-last-child(2) Selects every <p> element that is the second child of its parent, counting
from the last child
:nth-last-of-type(n) p:nth-last-of-type(2) Selects every <p> element that is the second <p> element of its parent,
counting from the last child
:nth-of-type(n) p:nth-of-type(2) Selects every <p> element that is the second <p> element of its parent
:only-of-type p:only-of-type Selects every <p> element that is the only <p> element of its parent
:only-child p:only-child Selects every <p> element that is the only child of its parent
:out-of-range input:out-of-range Selects input elements with a value outside a specified range
::placeholder input::placeholder Selects input elements with the "placeholder" attribute specified
:read-only input:read-only Selects input elements with the "readonly" attribute specified
:read-write input:read-write Selects input elements with the "readonly" attribute NOT specified
:required input:required Selects input elements with the "required" attribute specified
:target #news:target Selects the current active #news element (clicked on a URL containing that
anchor name)
CSS Functions
CSS functions are used as a value for various CSS properties.
Function Description
max() Uses the largest value, from a comma-separated list of values, as the property value
min() Uses the smallest value, from a comma-separated list of values, as the property value
Arial (sans-serif)
Verdana (sans-serif)
Tahoma (sans-serif)
Trebuchet MS (sans-serif)
Times New Roman (serif)
Georgia (serif)
Garamond (serif)
Courier New (monospace)
Brush Script MT (cursive)
Note: Before you publish your website, always check how your fonts appear on different browsers and devices,
and always use fallback fonts!
Below are some commonly used fallback fonts, organized by the 5 generic font families:
Serif
Sans-serif
Monospace
Cursive
Fantasy
Animatable properties can change gradually from one value to another, like size, numbers, percentage and
color.
Animatable Properties
These properties are animatable in CSS:
Property
aspect-ratioTry it
backgroundTry it
background-colorTry it
background-positionTry it
background-position-xTry it
background-position-yTry it
background-sizeTry it
block-sizeTry it
borderTry it
border-bottomTry it
border-bottom-colorTry it
border-end-end-radiusTry it
border-end-start-radiusTry it
border-blockTry it
border-block-colorTry it
border-block-end-colorTry it
border-block-end-widthTry it
border-block-start-colorTry it
border-block-start-widthTry it
border-block-widthTry it
border-bottom-left-radiusTry it
border-bottom-right-radiusTry it
border-inlineTry it
border-inline-colorTry it
border-inline-end-colorTry it
border-inline-end-widthTry it
border-inline-start-colorTry it
border-inline-start-widthTry it
border-inline-widthTry it
border-start-end-radiusTry it
border-start-start-radiusTry it
border-bottom-widthTry it
border-colorTry it
border-leftTry it
border-left-colorTry it
border-left-widthTry it
border-rightTry it
border-right-colorTry it
border-right-widthTry it
border-spacingTry it
border-topTry it
border-top-colorTry it
border-top-left-radiusTry it
border-top-right-radiusTry it
border-top-widthTry it
bottomTry it
box-shadowTry it
clipTry it
colorTry it
column-countTry it
column-gapTry it
column-ruleTry it
column-rule-colorTry it
column-rule-widthTry it
column-widthTry it
columnsTry it
filterTry it
flexTry it
flex-basisTry it
flex-growTry it
flex-shrinkTry it
fontTry it
font-sizeTry it
font-size-adjust
font-stretch
font-weightTry it
gridTry it
grid-areaTry it
grid-auto-columnsTry it
grid-auto-flowTry it
grid-auto-rowsTry it
grid-columnTry it
grid-column-endTry it
grid-column-gapTry it
grid-column-startTry it
grid-gapTry it
grid-rowTry it
grid-row-endTry it
grid-row-gapTry it
grid-row-startTry it
grid-templateTry it
grid-template-areasTry it
grid-template-columnsTry it
grid-template-rowsTry it
heightTry it
inline-sizeTry it
insetTry it
inset-blockTry it
inset-block-endTry it
inset-block-startTry it
inset-inlineTry it
inset-inline-endTry it
inset-inline-startTry it
leftTry it
letter-spacingTry it
line-heightTry it
marginTry it
margin-blockTry it
margin-block-endTry it
margin-block-startTry it
margin-bottomTry it
margin-inlineTry it
margin-inline-endTry it
margin-inline-startTry it
margin-leftTry it
margin-rightTry it
margin-topTry it
max-heightTry it
max-widthTry it
max-block-sizeTry it
max-inline-sizeTry it
min-block-sizeTry it
min-inline-sizeTry it
min-heightTry it
min-widthTry it
object-positionTry it
offset-anchorTry it
offset-distanceTry it
offset-pathTry it
offset-rotateTry it
opacityTry it
orderTry it
outlineTry it
outline-colorTry it
outline-offsetTry it
outline-widthTry it
paddingTry it
padding-blockTry it
padding-block-endTry it
padding-block-startTry it
padding-bottomTry it
padding-inlineTry it
padding-inline-endTry it
padding-inline-startTry it
padding-leftTry it
padding-rightTry it
padding-topTry it
perspectiveTry it
perspective-originTry it
rightTry it
rotateTry it
scaleTry it
text-decoration-colorTry it
text-indentTry it
text-shadowTry it
topTry it
transformTry it
transform-originTry it
translateTry it
vertical-align
visibility
width
word-spacingTry it
z-index