Scanner class Methods in Java

HTML Inline and Block Elements

Inline and Block elements

There are various types of elements in HTML. But most of elements are defined as block level or inline elements.

Block level Elements

Block level elements start with new line.They consume the full width of page.If you want to insert other element with this block element then the inserted element will always be displayed in new line after the block elements. Block element does not let other element to be within same width.

 for example,

<h1>,<form>,<li>,<ol>,<ul>,<p>,<pre>,<table>,<div>,etc.

Inline level Elements

Inline element does not consume the full with of web page. You can insert as many as elements with an inline element. Inline elements normally displayed without line breaks.

for example,

<b><a><strong>,<img>,<input>,<em>,<span>, etc.

The <div> element is a block element that is often used as container for other HTML elements.
When used together with some CSS styling, the <div> element can be used to style blocks of content.

for example,
<html>
<head>
<title>Block Elements</title>
</head>
<body>
<h1>Headline</h1>
<div style="background-color:greencolor:whitepadding:20px;">
<p>Some paragraph text goes here</p>
<p>Another paragraph goes here</p>
</div>
</body>
</html>
Result:

Block level element Div example in html

Similarly, the <span> element is an inline element that is often used as a container for text. When used together with CSS, The <span> element can be used to style parts of text.

for example,
<html>
<head>
<title>Inline Elements</title>
</head>
<body>
<h2>Some
<span style="color:green">important</span>
Message</h2>
</div>
</body>
</html>
Result:

Inline level element span example in html

The <div> element define a block-level  section in a document.
The <span> element defines an inline section in a document.

Other elements

Other elements can be either block level elements  or inline elements. This includes the following elements.

APPLET- embedded java applet.
IFRAMEinline frame
INS- inserted text
MAP- image map
OBJECT- embedded object
SCRIPT- script within HTML document

You can insert inline elements inside block  level elements. For example,you have multiple <spanelements inside a <divelement.

Inline elements cannot contain any block level element.

Comments