Understanding Inline-Level Elements

Description

inline value creates inline-level elements, which are displayed without adding line break before and after the element

Example

The following code changes p element to be an inline element.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
p {<!--from  w w  w .  j a v a 2  s  .co m-->
  display: inline;
}

span {
  display: inline;
  border: medium double black;
  margin: 2em;
  width: 10em;
  height: 2em;
}
</style>
</head>
<body>
  <p>This is a test.</p>
  <p>This is a test. <span>This is a test.</span>
     This is a test.
  </p>
</body>
</html>

Click to view the demo

When using the inline value, the browser will ignore certain properties, such as width, height, and margin. All three properties are defined for span in the code, are ignored by the browser.





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table