- Webp converter
- W3 HTML Validator
- Favicon generator
- What is my viewport
- Markdown previewer & syntax
- Special entities: ASCII codes
Headings tags are not only to control the size of the text, they also have their own meaning. We shouldn't write h2
headings without writting h1
heading before and so on.
It's important to structure the HTML code with this 3 tags,
header
must contain navigation menus, logos, social media links...footer
should contain usefull information, contact links, FAQs, creator name, the small print of the contracts...main
has all the relevant content of the page.
Content section labels, section can contain articles and articles can contain sections
section
: generic container used to group related content. When we are creating blocks wich content is related to an upper block we will use sections.article
: container that represents independent content, i.e. when we can read that fragment elsewhere and it would make sense on its own.aside
: used to display content that is related but not part of the main content. It can be placed inside or outside the main tag.
Nesting: section can contain articles, i.e. if we have some articles about HTML tags, they should be placed inside one section, due to they have related content, and articles would be independent because we could read one whitout reading the others and it would still have its own sense. Article is defined as component of the page with independent content, this tag could have a header and a footer.
Block elements will occupy the full available width even if their content does not, so the elements below will go to the following line. Line elements will take only the width they need, so it's possible to display more than one element in the same line. Each element has semantic value strong > em > normal > small. With these labels we can set the relevance of each part of the text.
- Line elements:
em
: emphasstrong
: more emphasissmall
: less emphasisbr
: line breakwbr
: We can select where the line breaks when needed. Same as '-'time
: dates and timesi
: italic (only style tag, no semantic value). Also icon tagu
: underline (only style tag, no semantic value)b
: bold (only style tag, no semantic value)sup
: adds supper indexessub
: adds sub indexes
Aditional values to modify the HTML tags or it's behaviour
- Common:
attribute="value"
- Boolean:
attribute
These attributes can be used in almost every HTML tag:
class
: to add a CSS classid
: to add identifierstitle
: accesibility tag to show element descriptionsdata-*
: allows to save values in the HTML tag
Links are very important, they allow us to navigate through the web or to other webs. It has one mandatory attribute href
with the route, it also has the target
attribute to modify how the resource will be displayed:
href
: absolute paths (with http:// or https://) for external webs: https://www.google.com, relative paths for internal pagestarget
: with absolute paths for external webs_blank
download
: download the file in the path, the file must be in our server. Best practices are to save the files under assets/files, images, icons ... We can navigate in the page to tags with id by using,href=#id-name
, this can be used to navigate to specific points in other pages like /other/other.html#someid
Used to list content, there are 3 types of lists:
ul
: unordered list: Order does not matters (used to create menus). It can has list type,to style the item marks (type="value"):- disc (default value)
- circle
- square
ol
: ordered list: Order does matter. It can has list type,to style the item marks (type="value"), it also has the start="value" attribute to star on a default value:- 1: (1, 2, 3 ...) (default value)
- A: (A, B, C ...)
- a: (a, b, c ...)
- I: (I, II, III ...)
- i: (i, ii, iii ...)
dl
: definition list: List of definitions (dictionary) Browsers differentiate between the type of site. Elements of the list are represented byli
tagul
andol
lists. Fordt
: list each element is represented with 2 tags:dt
: definition term: term to definedd
: definition description: term description
Tables are used to display tabbed content, this is the basic structure of one table:
table
: represents the tabletr
: table rowtd
: table data, one cell The number of cells inside a row sets the number of columns of the table. The title of the table can be setted with the optionalcaption
tag. We can set the header of the table with thethead
tag and theth
tag for each header. When we set athead
tag, we must place all the table content inside thetbody
tag. Tables can also have a footertfoot
. We can modify the space of each cell, we have the following attributes:rowspan
the cell will take more than one row. (default value 1). It will take the space of the next rows. Common errorcolspan
the cell will take more than one col. (default value 1) We can group cols with thecolgroup
tag.
More block tags:
address
: adds contact information to the nearest artible or the bodyblockquote
: used to mark citations to other authors or documents. It can has the attributecite=""
to reference the source of the contentpre
: used to maintain the format of the text (tabs, end of lines ..) i.e. to print some formated code.div
: used to split the document, no semantic meaning, generic container normally used for styling from csshr
: horizontal rule, the browser understands that there is a change of subject. Don't use it to draw lines
More line tags:
span
: line container, equals div, is used to enclose words or small texts and style them through CSS or localise them from JS, it has no semantic meaning.q
: equivalent to blockquote, means quoute. To put quotations in line.code
: to enclose code that we want to represent visually, it usually goes with the pre tag. It has semantic meaning.- Special entities: ASCII codes
Basic form structure:
form
: wraps the formaction=""
: where to send the data (server, other html ..)method=""
: method to execute GET/POST
label
: sets the field labelfor="fieldID"
: matches the label to the field
input
: field to allow users to enter dataname
: mandatory
button
: allow users perform an acction
The default behaviour of forms reloads the current page Related form tags
fieldset
: used to group elements inside the formlegend
: label for the fieldset contentmeter
: represents a value within a rangeprogress
: progress of a tasktextarea
: multiline text input
Most frequent field attributes:
placeholder
:required
: mandatory fieldreadonly
: readonly fieldmin - max
: for number inputmaxlenght - minlenght
: for text inputselected
: to set a default valuedisabled
: disabled fieldautofocus
: sets the focus on the field
button
: same as<button></button>
but it doesn't reloads the page. Doesn't send the data.color
: choose a colordate
: enter a datedatetime
: Deprecateddatetime-local
: date and time, doesn't works on firefoxemail
: enter emailhidden
: hidden field, could have a value but it isn't shownmonth
: enter a monthweek
: enter a week numbernumber
: numeric valuespassword
: passwords ***range
: set a range -step="10"
: how much the bar moves -min="0"
: min value -max="30"
: max valuereset
: reset the formssearch
: search barssubmit
: sends the formtel
: phone numberstext
: default value plain textstime
: hoursurl
: URLsfile
: files
radio
: select only one optionname="category"
: sets the category to which the radio belongs and allows only one value per categoryvalue=""
: what is the value of the elementchecked
: radio checked by default
checkbox
: select multiple options- Needs name and value as radio inputs
select
: select from a listname="category"
: sets the categorymultiple
: allow to select more than one option<option>
: each option goes in tags, if there are lots of options, we can group them in<optgroup>
and set alabel
atribute for each group. If hasselected
attribute, it's selected by default
list
: filter with the text in the related datalistlist="datalistID"
it also shows the value attribute of the tag, each element of the list is oneoption
tag
All the content that we retrive from outside our web. Usually these are the heaviest files on the web page (images, videos ..)
- Pictures: There are two images types:
- Vectorial SVG (very ligth) icons logos ..
- Bit map: jpg, png (8/24), gif, webp (recommended)
- Audio
- Video
- Iframes Usually placed on /assets
Relation between the real amount of pixels of the devide and the available pixels to "draw" content DPR = real pixels / avaliable pixels On mobile devices, its usually 2.4 - 3
- Viewport: available space to draw (1920 x 1080) What is my viewport
We shouldn't use the same image for mobile devices and for desktop, it's a big file that is not necessary on mobile devices. We can use one image or other depending on the device. We can do this with the
srcset
attribute, doesn't work on IE so we can also addsrc
attribute.
When using the tags <picture> - <source>
to display images, if the paths provided for the img tag is invalid the browser won't render any image. It works like a js switch, we set the sources for each case and its default fallback images, and the default picture is on img tag.
Inserted with <img>
tag
src=""
: route to the imagealt=""
: description of the image We can isert SVG images with the image tag or with the svg content on the html. The second option is only if we need to access the svg properties (i.e. to animate it from js)
The audio tag allows to insert audio content on the web, it has:
src=""
: with the path to the audio filecontrols
: to dysplay controls of the songautoplay
: starts the audio on page load. If the content isn't muted the browser will stop autoplayloop
: auto-replay
The video tag allows to insert video content on the web, it has:
src=""
: with the path to the video filecontrols
: to dysplay controls of the songautoplay
: starts the video on page load. If the content isn't muted the browser will stop autoplayloop
: auto-replayposter
: sets the preview image
We can insert pieces of web from other pages (twitter, instagram ...), the madatory attributes are:
width
andheigth
src
: uri to the content Performance is affected
Attribute list of meta tag, usually formed with name=""
and content=""
:
charset
: codificationtitle
: Web titleviewport
: Allows rendering the page on mobile devicesdescription
: Sumary shown when the link is displayed on web searchsauthor
Very extended subject, this is the basics. There are voice-browsers that dictate the content of the page to you.
tabindex
: sets the orden when navigating using tab.aria-label
: audio description of the contentrole
: audio description of element type
Developed by facebook, we can customice what the user will see when they copy our link page in other platforms, like twitter, facebook.. We can set a title, descriptiion, poster
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="https://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="https://ia.media-imdb.com/images/rock.jpg" />
...
</head>
Similar to opg, but for twitter
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@nytimes">
<meta name="twitter:creator" content="@SarahMaslinNir">
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
<meta name="twitter:description" content="NEWARK - The guest list and parade of limousines with celebrities emerging from them seemed more suited to a red carpet event in Hollywood or New York than than a gritty stretch of Sussex Avenue near the former site of the James M. Baxter Terrace public housing project here.">
<meta name="twitter:image" content="http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg">