\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Robert Jacobson (Xyzzy)} \pdfinfo{ /Title (html.pdf) /Creator (Cheatography) /Author (Robert Jacobson (Xyzzy)) /Subject (HTML Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{000000} \definecolor{LightBackground}{HTML}{F7F7F7} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{HTML Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Robert Jacobson (Xyzzy)} via \textcolor{DarkBackground}{\uline{cheatography.com/1118/cs/400/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Robert Jacobson (Xyzzy) \\ \uline{cheatography.com/xyzzy} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 6th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML structure}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\textless{}{\bf{!DOCTYPE html}}\textgreater{} \newline % Row Count 1 (+ 1) \textless{}!-{}-{\bf{ comments}} -{}-\textgreater{} \newline % Row Count 2 (+ 1) \textless{}{\bf{html}}\textgreater{} \newline % Row Count 3 (+ 1) .. \textless{}{\bf{head}}\textgreater{} \newline % Row Count 4 (+ 1) .... \textless{}{\bf{title}}\textgreater{}...\textless{}/title\textgreater{} \newline % Row Count 5 (+ 1) .. \textless{}/head\textgreater{} \newline % Row Count 6 (+ 1) .. \textless{}{\bf{body}}\textgreater{} \newline % Row Count 7 (+ 1) .. \textless{}/body\textgreater{} \newline % Row Count 8 (+ 1) \textless{}/html\textgreater{}% Row Count 9 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML head}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Title}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\textless{}title\textgreater{}{\emph{text}}\textless{}/title\textgreater{}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{CSS stylesheet link}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\textless{}link href="URL.css" type="text/css" rel="stylesheet" /\textgreater{}} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Page icon}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\textless{}link href="URL.ico" type="image/ico" rel="shortcut icon" /\textgreater{}} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{JavaScript link}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\textless{}script src="URL.js" type="text/javascript"\textgreater{}\textless{}/script\textgreater{} {\emph{(not self-closing)}}} \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Metadata}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\textless{}meta {\emph{attribute="value"}} ... /\textgreater{}} \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.23505 cm} x{1.74195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML block elements}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}{\bf{p}}\textgreater{} & Paragraph text \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}{\bf{h1}}\textgreater{}, \textless{}{\bf{h2}}\textgreater{}, ...\textless{}{\bf{h6}}\textgreater{} & Heading 1 to 6 \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \textless{}{\bf{hr}} /\textgreater{} & Horizontal rule \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \textless{}{\bf{blockquote}}\textgreater{} & Blockquote \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \textless{}{\bf{pre}}\textgreater{} & Preformatted text \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \textless{}{\bf{form}}\textgreater{} & Form \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{}{\bf{fieldset}}\textgreater{} & Fieldset \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} \textless{}{\bf{address}}\textgreater{} & Contact info \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} \textless{}{\bf{div}}\textgreater{} & Content block \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Additional HTML5 content tags: \textless{}audio\textgreater{}, \textless{}canvas\textgreater{}, \textless{}video\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.9862 cm} x{1.9908 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML body - inline elements}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}{\bf{a}} href="URL"\textgreater{} & Hyperlink \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}{\bf{img}} src="URL" {\bf{alt}}="..." /\textgreater{} & Image \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \textless{}{\bf{br}} /\textgreater{} & Line break \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \textless{}{\bf{em}}\textgreater{} & Emphasis (italic) \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \textless{}{\bf{strong}}\textgreater{} & Strong (bold) \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \textless{}{\bf{q}}\textgreater{} & Quotation \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \textless{}{\bf{code}}\textgreater{} & Code (monospace) \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} \textless{}{\bf{abbr}} title="text"\textgreater{} & Abbreviation \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} \textless{}{\bf{del}}\textgreater{} & Deleted (strikethrough) \tn % Row Count 12 (+ 2) % Row 9 \SetRowColor{white} \textless{}{\bf{ins}}\textgreater{} & Inserted (underline) \tn % Row Count 14 (+ 2) % Row 10 \SetRowColor{LightBackground} \textless{}{\bf{sub}}\textgreater{} & Subscript \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} \textless{}{\bf{sup}}\textgreater{} & Superscript \tn % Row Count 16 (+ 1) % Row 12 \SetRowColor{LightBackground} \textless{}{\bf{span}}\textgreater{} & Span \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML lists (block elements)}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}{\bf{ol}}\textgreater{} & Ordered list \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}{\bf{ul}}\textgreater{} & Unordered list \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{}{\bf{li}}\textgreater{} & List item \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textless{}{\bf{dl}}\textgreater{} & Definition list \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \textless{}{\bf{dt}}\textgreater{} & Definition term \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \textless{}{\bf{dd}}\textgreater{} & Definition description \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Nested list: \newline \textless{}{\bf{ol}}\textgreater{} \newline .. \textless{}{\bf{li}}\textgreater{} content \textless{}/li\textgreater{} \newline .. \textless{}{\bf{li}}\textgreater{} content \textless{}/li\textgreater{} \newline .. \textless{}{\bf{li}}\textgreater{} \newline .... \textless{}{\bf{ul}}\textgreater{} \newline ...... \textless{}{\bf{li}}\textgreater{} nested item \textless{}/li\textgreater{} \newline ...... \textless{}{\bf{li}}\textgreater{} nested item \textless{}/li\textgreater{} \newline .... \textless{}/ul\textgreater{} \newline .. \textless{}/li\textgreater{} \newline \textless{}/ol\textgreater{} \newline \newline Definition list: \newline \textless{}{\bf{dl}}\textgreater{} \newline .. \textless{}{\bf{dt}}\textgreater{} term 1 \textless{}/dt\textgreater{} \newline .. \textless{}{\bf{dd}}\textgreater{} description 1 \textless{}/dd\textgreater{} \newline .. \textless{}{\bf{dt}}\textgreater{} term 2 \textless{}/dt\textgreater{} \newline .. \textless{}{\bf{dd}}\textgreater{} description 2 \textless{}/dd\textgreater{} \newline \textless{}/dl\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \columnbreak \begin{tabularx}{5.377cm}{x{3.4839 cm} x{1.4931 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML tables (block elements)}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}{\bf{table}}\textgreater{} & Table \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}{\bf{colgroup}} span="{\emph{cols}}"\textgreater{} & Column group \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{}{\bf{col}} {\emph{attributes}} /\textgreater{} & Column \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textless{}{\bf{caption}}\textgreater{} & Caption \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \textless{}{\bf{tr}}\textgreater{} & Table row \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \textless{}{\bf{th}}\textgreater{} & Table heading \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} \textless{}{\bf{td}}\textgreater{} & Table cell \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \textless{}{\bf{thead}}\textgreater{}, \textless{}{\bf{tfoot}}\textgreater{}, \textless{}{\bf{tbody}}\textgreater{} & Containers (opt) \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\textless{}{\bf{table}}\textgreater{} \newline .. \textless{}{\bf{caption}}\textgreater{} text \textless{}/caption\textgreater{} \newline .. \textless{}{\bf{col}} {\emph{attributes}} /\textgreater{} \newline .. \textless{}{\bf{colgroup}}\textgreater{} \newline ....\textless{}{\bf{col}} {\emph{attributes}} /\textgreater{} \textless{}{\bf{col}} {\emph{attributes}} /\textgreater{} \newline .. \textless{}/colgroup\textgreater{} \newline .. \textless{}{\bf{tr}}\textgreater{} \newline .... \textless{}{\bf{th}}\textgreater{} heading 1 \textless{}/th\textgreater{} \newline .... \textless{}{\bf{th}}\textgreater{} heading 2 \textless{}/th\textgreater{} \newline .. \textless{}/tr\textgreater{} \newline .. \textless{}{\bf{tr}}\textgreater{} \newline .... \textless{}{\bf{td}}\textgreater{} cell 1 \textless{}/td\textgreater{} \newline .... \textless{}{\bf{td}}\textgreater{} cell 2 \textless{}/td\textgreater{} \newline .. \textless{}/tr\textgreater{} \newline \textless{}/table\textgreater{} \newline \newline Alternate (no inner col tags): \newline \textless{}colgroup {\emph{attributes}} span="3 \textgreater{}\textless{}/colgroup\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{1.64241 cm} p{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{HTML characters}} \tn % Row 0 \SetRowColor{LightBackground} \textless{} & \< \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textgreater{} & \&gr; \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \& & \& \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} " & \" \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} (c) & \© \tn % Row Count 5 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{HTML URL format}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Relative (same directory)} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}"filename"} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Relative (subdirectory)} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}"subfolder/filename"} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Relative (parent)} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}"../filename"} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Relative (root)} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}"/path/filename"} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Absolute} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}\seqsplit{"http://domain/path/file"}} \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}