inline-block elements code example

Example 1: html inline elements

Inline elements in HTML:

1	<a>			    The <a> tag defines a hyperlink, which is used to link from one page to another.
2	<abbr>			The <abbr> tag defines an abbreviation or an acronym, like "HTML", "Mr.", "Dec.", "ASAP", "ATM".
3	<acronym>		The <acronym> tag is not supported in HTML5. Use the <abbr> tag instead.
4	<b>			    The <b> tag specifies bold text without any extra importance.
5	<bdo>			The <bdo> tag is used to override the current text direction.
6	<big>			The <big> tag defines bigger text.
7	<br>			The <br> tag inserts a single line break.
8	<button>		The <button> tag defines a clickable button.
9	<cite>			The <cite> tag defines the title of a work (e.g. a book, a song, a movie, a TV show, a painting, a sculpture, etc.).
10	<code>			The <code> tag is a phrase tag. It defines a piece of computer code.
11	<dfn>			The <dfn> tag represents the defining instance of a term in HTML.
12	<em>			The <em> tag is a phrase tag. It renders as emphasized text.
13	<i>			    The <i> tag defines a part of text in an alternate voice or mood. The content of the <i> tag is usually displayed in italic.
14	<img>			The <img> tag defines an image in an HTML page.
15	<input>			The <input> tag specifies an input field where the user can enter data.
16	<kbd>			The <kbd> tag is a phrase tag. It defines keyboard input.
17	<label>			The <label> tag defines a label for several elements
18	<map>			The <map> tag is used to define a client-side image-map. An image-map is an image with clickable areas.
19	<object>		The <object> tag defines an embedded object within an HTML document. Use this element to embed multimedia (like audio, video, Java applets, ActiveX, PDF, and Flash) in your web pages.
20	<output>		The <output> tag represents the result of a calculation (like one performed by a script).
21	<q>			    The <q> tag defines a short quotation.
22	<samp>			The <samp> tag is a phrase tag. It defines sample output from a computer program.
23	<script>		The <script> tag is used to define a client-side script (JavaScript).
24	<select>		The <select> element is used to create a drop-down list.
25	<small>			The <small> tag defines smaller text (and other side comments).
26	<span>			The <span> tag is used to group inline-elements in a document.
27	<strong>		The <strong> tag is a phrase tag. It defines important text.
28	<sub>			The <sub> tag defines subscript text. Subscript text appears half a character below the normal line, and is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O.
29	<sup>			The <sup> tag defines superscript text. Superscript text appears half a character above the normal line, and is sometimes rendered in a smaller font. Superscript text can be used for footnotes, like WWW[1].
30	<textarea>		The <textarea> tag defines a multi-line text input control.
31	<time>			The <time> tag defines a human-readable date/time.
32	<tt>			The <tt> tag defines teletype text.
33	<var>			The <var> tag is a phrase tag. It defines a variable.

Example 2: make div tag inline

<div class="inline">1<br />2<br />3</div>
<div class="inline">1<br />2<br />3</div>
<div class="inline">1<br />2<br />3</div>
<br class="clearBoth" /><!-- you may or may not need this -->

Example 3: Inline Element

Note: An inline element cannot contain a block-level element!

Example 4: css block layout

/******************* BASIC BLOCK DISPLAY **********************/

/**************** Block display Elements  *********************/
/*Elements that block any other elements from being in the 
same line. You can change the width from being the maximum 
width of the page, but you can´t put elements side by side */
tag_name {
    display: block;
}

/*Exemple of default block display elements:*/
<h1> ... </h1>
<p> ... </p>


/**************** Inline display Elements  *********************/
/*They are the type of blocks that only take up the minimum space 
required (both in width and height). You can place these types of 
blocks side by side (on the same line) but you cannot change their 
dimensions */

tag_name {
    display: inline;
}

/*Exemple of default inline display elements:*/
<spans> ... </spans>
<img> ... </img>
<a> ... </a>


/************* Inline-block display Elements  *****************/
/*They take the best of the two other types above. You can put 
elements side by side (on the same line) and you can change this 
block width and height */

tag_name {
    display: inline-block;
}


/***************** None display Elements  ********************/
/*This block will never appear on your webpage and will never 
interact with the other elements (it doesn't take up space) */

tag_name {
    display: none;
}

Example 5: what does display inline-block do?

/*Compared to display: inline, the major difference is that
display: inline-block allows to set a width and height on the element.

Also, with display: inline-block, the top and bottom margins/paddings are
respected, but with display: inline they are not.

Compared to display: block, the major difference is that
display: inline-block does not add a line-break after the element,
so the element can sit next to other elements.

The following example shows the different behavior of
display: inline, display: inline-block and display: block: */


span.a {
  display: inline; /* the default for span */
  width: 100px;
  height: 100px;
  padding: 5px;
  border: 1px solid blue;
  background-color: yellow;
}

span.b {
  display: inline-block;
  width: 100px;
  height: 100px;
  padding: 5px;
  border: 1px solid blue;
  background-color: yellow;
}

span.c {
  display: block;
  width: 100px;
  height: 100px;
  padding: 5px;
  border: 1px solid blue;
  background-color: yellow;
}

Example 6: list is an inline element?

yes, list is an inline-block element

Tags:

Misc Example