I have multiple rows of texts and divs like this:  &lt;div&gt;   &lt;span&gt;Adeline&lt;/span&gt;&lt;div style="display:inline; height:20px, width:20px, background-color: blue"&gt;hi&lt;/div&gt; &lt;/div&gt; &lt;div&gt;   &lt;span&gt;Ted&lt;/span&gt;&lt;div style="display:inline; height:20px, width:20px, background-color: green"&gt;hi&lt;/div&gt; &lt;/div&gt; &lt;div&gt;   &lt;span&gt;Sara&lt;/span&gt;&lt;div style="display:inline; height:20px, width:20px, background-color: coral"&gt;hi&lt;/div&gt; &lt;/div&gt;   How can I make sure in each row the span and the div are vertically aligned?
555
I have a div with two images and an h1. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be absolute positioned within the div. What is the CSS needed for this to work on all common browsers? &lt;div id=&quot;header&quot;&gt;   &lt;img src=&quot;..&quot; &gt;&lt;/img&gt;   &lt;h1&gt;testing...&lt;/h1&gt;   &lt;img src=&quot;...&quot;&gt;&lt;/img&gt; &lt;/div&gt;
66655
I tried to combine this answer  with my answer  But the pdflatex -shell-escape table.tex ignores linebreaks and the 3 tables are horizontally aligned and not vertically. table.tex \documentclass[convert]{standalone} % \documentclass{article}  \usepackage{booktabs} % for nice lines \usepackage{siunitx}  % nice numbers and units and 'S' in table \usepackage{multirow} % enable \multirow command  \begin{document} short answer to your question:\\ \begin{tabular}{|c|c|S|} \hline Genre &amp; Name &amp; {Weight}\\\hline Humain &amp; Aragorn &amp; 102 \\\hline \multirow{4}{*}{Hobbit}&amp;Frodon &amp; 32.1\\\cline{2-3}     &amp;Sam &amp; 3.2 \\\cline{2-3}     &amp;Peregrin &amp; 2.232\\\cline{2-3}     &amp;Meriadoc &amp; 23 \\\hline Elfe&amp;Legolas &amp; 34.5 \\\hline \end{tabular}\\[1cm]   You can also use the power of booktabs and siunitx:\\ \begin{tabular}[ht]{l c S} % alignment l = left, c = centre, S = at decimal - needs siunitx \toprule Genre&amp;Name&amp; {Weight}\\  % protect non numbers with {} in S columns \midrule Elfe&amp;Legolas &amp; 34.5\\ Dwarf&amp;Peter &amp; 103.31\\ \bottomrule \end{tabular}\\[1cm]  And combine that with your table:\\ \begin{tabular}{c c S} \toprule Genre &amp; Name &amp; {Weight}\\\midrule Humain &amp; Aragorn &amp; 102 \\\midrule \multirow{4}{*}{Hobbit}&amp;Frodon &amp; 32.1\\\cline{2-3}     &amp;Sam &amp; 3.2 \\\cline{2-3}     &amp;Peregrin &amp; 2.232\\\cline{2-3}     &amp;Meriadoc &amp; 23 \\\midrule Elfe&amp;Legolas &amp; 34.5 \\ \bottomrule \end{tabular}   \end{document}
116938
I want to create page with two columns with different background color and height of whole page. What I was able to do is two columns with different background color but I can't set proper height and there is small gap between two columns and another gap between top of the page and top of the columns. I want to remove these gaps. Also I want to create vertical line between two columns. Right now I have minipages packed inside \colorbox which allows me to create all four borders but I only want one.   Final effect should look like this:    This is what I figured out for now:  \documentclass{article} \usepackage{blindtext} \usepackage{xcolor} \usepackage{geometry} \geometry{margin=0in}  \begin{document} \noindent \fcolorbox{black}{red}{ \begin{minipage}{.3\textwidth}   test \end{minipage} } \fcolorbox{yellow}{yellow}{ \begin{minipage}{.7\textwidth}   test \end{minipage} } \end{document}
54409
I had tried to increase the number from 2 to 4 where I need 4 lines  \multirow{4}{*}{\thead{Pair number \\ (Class 11 sample sample \&amp; \\ Class 22 sample sample \\ Reference X sample sample)}} &amp;      \documentclass[12pt,oneside]{book}  \usepackage[showframe]{geometry} \usepackage{amsmath} \usepackage{ragged2e} \usepackage{makecell, multirow, tabularx} \renewcommand\theadfont{\small\bfseries} % for bold in table using \small \renewcommand\theadgape{} \usepackage[svgnames, table]{xcolor} \usepackage{hhline, boldline} \usepackage{seqsplit, caption} %for table spacing to second row \usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text \usepackage{siunitx} %for table spacing to second row \usepackage{threeparttable} %to add footnote below table \usepackage{tabulary} \usepackage{graphicx}  \usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}  \begin{document}   \begin{table}[h!] \centering \sisetup{table-format=3.0, table-number-alignment=center, table-column-width=2.0cm}  \begin{tabular}{lrr}     \toprule      \multirow{4}{*}{\thead{Pair number \\ (Class 11 sample sample \&amp; \\ Class 22 sample sample \\ Reference X sample sample)}} &amp;  \multicolumn{2}{c}{\thead{\makebox[0pt]{Accuracy Accu Accuracy (\%)}}}\\ \cmidrule{2-3}     &amp;{\textbf{Accuracy}}      &amp; {\textbf{Inaccuracy}} \\      \midrule     Pair 11 (A8 \&amp; B35) &amp; 0  &amp;   0 \\     Pair 12 (A10 \&amp; B42) &amp; 0   &amp;  0 \\     Pair 13 (A8 \&amp; B32) &amp; 0   &amp;  0 \\         \bottomrule     \end{tabular} \end{table}   \end{document}
69563
There's something wrong with the vertical alignment on the :   (click to enlarge)  On the , which uses a similar list but without the Favorite column, the vertical alignment is correct.  (Tested in the latest Firefox, Safari and Chrome on macOS Catalina.)
116167
I'm trying to set up a table with some equations in it, however I would like the equations on multiple rows to be aligned properly. So far I have  \begin{tabular}{cc} \hline \multicolumn{1}{l}{Header 1} \\ \hline $a = \sum_j b(c)$ &amp; $c = d$ \\ \hline \multicolumn{1}{l}{Header 2} \\ \hline $\begin{aligned}          e&amp;=fghij(y) \\          klm(x)&amp;=nop         \end{aligned}$ &amp;        $\begin{aligned}         qr&amp;=vwxyzstu \\         abcde&amp;=fghij         \end{aligned}$ \end{tabular}   which looks like    Note how the equals signs in the top row are not aligned with the corresponding equals signs in the bottom two rows.   So my question is; is there a way to align across different rows or am I going about this completely the wrong way?
6298
Best way to center a &lt;div&gt; element on a page both vertically and horizontally?  I know that margin-left: auto; margin-right: auto; will center on the horizontal, but what is the best way to do it vertically, too?
37341
When styling text on web pages, both font size and line height can be set. For example, the text of this post will be displayed using a font-size of 14px and a line-height of (about) 18px, set using the value 1.3em.  Looking at other websites, it seems that a ratio around 1.2 is a common practice.  What is the best practice regarding this? What are some good resources from which I can learn more on the subject?
6523
I am trying to achieve a table where a few things have to work simultaneously. Several of these things have been discussed before, but I have been unable to make everything work at once (and some things at all).  I want to be able to use different font sizes in cells on the same row, and have them precisely aligned at the top. That has almost been achieved in the MWE below, but the letters of the smaller font are slightly below the letters of the larger font. (Previous discussion: , but the alignment is only close, not perfect.)  Edit: The top alignment should be for the maximum height of the font used, so that an 'a' ends up at the same height whether it is written by itself or followed by a tall letter, such as an 'l' (or, if the small 'b' next to the big 'B' in the example below is changed for a small 'a', the 'a' should not jump up to the ceiling.  I also want to be able to insert several rows of text with forced line breaks within a cell of the table, and those rows need to have the same spacing between them as normal text has. That has been achieved by nesting another table in a cell in the MWE below.  In addition, I want to be able to use \hfill to put something out in the right margin from within the nested table, which works in the MWE.  Further, the margins on the top, bottom and sides of the table should be zero, so that only the page margins determine the amount of white space around the table (as it is now, there is even a difference between the right and left margins -- although the margins were for some reason adjusted when I uploaded the pdf below, it is visible if you compile the code and look at the pdf directly).  Lastly, I would like to get rid of all automatic spacing between cells, and then define my own spacing. Preferably, I would like to be able to define the vertical spacing between cells in terms of line heights (for lines of the size that I specify for normal text, so 11pt in the example below), while the units of horizontal spacing would preferably be defined in terms of "the width of an 'm'", or something like that.  \documentclass[paper=a4,fontsize=11pt]{scrartcl} % KOMA-article class \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[english]{babel} % English language/hyphenation \usepackage{geometry} \usepackage{tabu} \usepackage{lipsum}  \pagestyle{empty} % No pagenumbers/headers/footers  \newcolumntype{V}{&gt;{\vspace{0pt}}p}  \begin{document} \begin{tabular} [t]{@{}V{0.2\columnwidth}V{0.8\columnwidth}} % @{} is used to remove the margins from cells \Huge\textbf A &amp; \begin{tabular}[t]{@{}p{0.8\columnwidth}} Lorem ipsum \hfill right-aligned\\ sem.\\ Lorem\\ ipsum \end{tabular} \\  \Huge\textbf B &amp; b \\  \Huge\textbf C &amp; \lipsum*[1] \\  \end{tabular} \end{document}     Edit 2013-03-25: I tried a different approach (with minipages) and asked a question: . As of writing this, I have one answer that is similar to the accepted answer below. It achieves correct spacing, but is limited to different sizes in the left column (if one wants to use \hfill in the right column), and the top alignment for the \Huge text is not perfect.  Edit 2013-03-25: I got an answer in the thread  where \strut was used to add space, and \vphantom{Qp} (adds the vertical space of what is written in the braces(Qp in this example)). That could most likely be used here to, to get the correct spacing between cells even if only short letters or letters that do not protrude downwards are used.
54749
I want a table whose first column is aligned top, second column is aligned middle, and third column is aligned bottom; like this:    I wrote the following code:  \documentclass{article} \usepackage[english]{babel} \usepackage{array}  \begin{document}  \begin{tabular}{| p{1cm} | m{1cm} | b{1cm} |}     \hline     x &amp;     A long text comes here &amp;     x \\ \hline \end{tabular}  \end{document}   Yet, to my surprise, the outcome was "all columns aligned middle," as follows:    What did I do wrong?
51129
I have multiple align environments in my document, separated by a small paragraph of text:  \begin{align*}   foo &amp;= something very very long compared to the other align \end{align*} explanation what I shall do now \begin{align*}   foo' &amp;= foo + short \end{align*}   As the text in the second align is considerably shorter, the = signs don't line up, which is to be expected.  Is there some way to make the two equals signs line up with eachother?
57437
I'm finishing my Msc. Thesis and I'm facing the last problems with some tabular, I'm not able to align this one.  \documentclass[12pt,a4paper,oneside,openright]{book} \usepackage{adjustbox} \usepackage{array} \usepackage{dcolumn} \usepackage{amsmath,amssymb}    \usepackage{amsthm} \usepackage{booktabs}  \usepackage{caption}   \usepackage{multirow} \usepackage{siunitx}  \usepackage{tabularx} \usepackage{ltablex} \usepackage{makecell}  \begin{document} \begin{table} \centering \caption{Analisi variabile tasso di interesse\label{tab:stat:tasso}} \begin{tabular}{p{3cm}p{3cm}} \toprule Data di segnalazione &amp; \makecell[ccc]{\% \\ Tasso di interesse\\ medio} \\ \toprule 2014h1 &amp; 3.59\\ 2014h2 &amp; 3.44 \\ 2015h1 &amp; 3.37 \\ 2015h2 &amp; 3.82 \\ 2016h1 &amp; 3.68 \\ \bottomrule Media &amp; 3.58 \\ \end{tabular}% \end{table}% \end{document}
2807
Given a template where the HTML cannot be modified because of other requirements, how is it possible to display (rearrange) a div above another div when they are not in that order in the HTML? Both divs contain data that varies in height and width.  &lt;div id="wrapper"&gt;     &lt;div id="firstDiv"&gt;         Content to be below in this situation     &lt;/div&gt;     &lt;div id="secondDiv"&gt;         Content to be above in this situation     &lt;/div&gt; &lt;/div&gt; Other elements   Hopefully it is obvious that the desired result is:  Content to be above in this situation Content to be below in this situation Other elements   When the dimensions are fixed it easy to position them where needed, but I need some ideas for when the content is variable. For the sake of this scenario, please just consider the width to be 100% on both.  I am specifically looking for a CSS-only solution (and it will probably have to be met with other solutions if that doesn't pan out).   There are other elements following this. A good suggestion was mentioned given the limited scenario I demonstrated&mdash;given that it might be the best answer, but I am looking to also make sure elements following this aren't impacted.
26519
I'm pretty sure this is a simple question in regards to formatting but here's what I want to accomplish:  I want to output data onto the screen using cout.  I want to output this in the form of a table format.  What I mean by this is the columns and rows should be properly aligned.  Example:  Test                 1 Test2                2 Iamlongverylongblah  2 Etc                  1   I am only concerned with the individual line so my line to output now (not working) is  cout &lt;&lt; var1 &lt;&lt; "\t\t" &lt;&lt; var2 &lt;&lt; endl;  Which gives me something like:  Test                 1 Test2                  2 Iamlongverylongblah         2 Etc                  1
112335
Lets say I have a text box that I want to fill a whole line. I would give it a style like this:  input.wide {display:block; width: 100%}   This causes problems because the width is based on the content of the text box. Text boxes have margin, borders, &amp; padding by default, which makes a 100% width text box larger than its container.  For example, here on the right:    Is there any way to make a text box fill the width of its container without expanding beyond it?  Here is some example HTML to show what I mean:  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head&gt;     &lt;title&gt;Untitled Page&lt;/title&gt;     &lt;style type="text/css"&gt;         #outer{border: 1px solid #000; width: 320px; margin: 0px;padding:0px}         #inner{margin: 20px; padding: 20px; background: #999;border: 1px solid #000;}         input.wide {display:block; margin: 0px}         input.normal {display:block; float: right}     &lt;/style&gt; &lt;/head&gt; &lt;body&gt;     &lt;div id="outer"&gt;         &lt;div id="inner"&gt;             &lt;input type="text" class="wide" /&gt;             &lt;input type="text" class="normal" /&gt;             &lt;div style="clear:both;"&gt;&lt;/div&gt;         &lt;/div&gt;     &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;   If this is run, you can see by looking at the "normal" text box that the "wide" text box is sticking out beyond the container. The "normal" text box floats to the actual edge of the container. I'm trying to make the "wide" text box fill its container, without expanding beyond edge like the "normal" text box is.
67076
I'd like to create something similar to what is give below: text on either side of a vertically centred image:
120101
Curious about text alignment on websites. For a blog, for example, is it better to have left-aligned or justified text? I like the look of justified text but I'm not sure if there's any downsides to it.