Cascading Style Sheet CSS

  Home  World Wide Web  Cascading Style Sheet CSS


“Learn Cascading Style Sheet CSS with Interview Questions and Answers and examples.”



26 Cascading Style Sheet CSS Questions And Answers

21⟩ What Are the Formatting Behaviors of HTML Elements?

From a formatting behavior point of view, HTML elements can be divided into 2 categories:

► Block Element - Formatted as a rectangular block occupying the entire width of the parent content box. For example, <P> is block element.

► Inline Element - Formatted as a rectangular block joining other inline elements horizontally to form a line of inline elements. If the width of the parent content box is reached, it will be wrapped to start a new line. One or more lines of in-line elements become a block element. For example, <IMG> is an inline element.

 201 views

22⟩ What Is the HTML Element Formatting Model in CSS?

An HTML document is divided into HTML elements. Each element is considered as a formatting unit using a box-oriented formatting model, which has:

► Content Box - A rectangular area for displaying the element content.

► Padding Box - A rectangular area surrounding the content box acting as padding space.

► Border Box - A rectangular area surrounding the padding box acting as border lines.

► Margin Box - A rectangular area surrounding the border box acting as margin space.

 215 views

23⟩ What Is a Block Element in CSS?

A block element is formatted as a rectangular block occupying the entire width of the parent content box. Examples of block elements are:

► <P> - A paragraph of text and/or inline elements.

► <PRE> - A paragraph of text with white spaces preserved.

► <LI> - A list item. Identical to <P; except that it has list-item marker on the left.

► <TABLE> - A table of cells. Each cell is identical to <P>

► <FORM> - An input form. Identical to <P> except that it has no margins.

► <DIV> - A container to group elements into a block element.

► <H1/H2/H3...> - A title line. Identical to <P> except that it has different margins and font size

► <HR> - A horizontal ruler.

 194 views

24⟩ What Is Inline Element in CSS?

An inline element is formatted as a rectangular block joining other inline elements horizontally to form a line of inline elements. If the width of the parent content box is reached, it will be wrapped to start a new line. One or more lines of in-line elements become a block element. Examples of inline elements are:

► <IMG> - A tag to insert an image into the current line.

► <STRONG> - A tag to make the text stronger.

► <EM> - A tag to emphasize the text

► <INPUT> - A tag to allow user entering input data to a form.

► <SPAN> - A container to group inline elements into a unit.

► <A> - A tag to create a hyper link.

► <BR> - A tag to break the current line.

 218 views

25⟩ What Is a Floating Element in CSS?

A floating element is a block element or in-line element being specified with the "float" style property. If "float: left" is specified, a floating element will be formatted at the left margin of the parent element. The current block and sub sequent blocks will be floated on the right side of this floating element.

If "float: right" is specified, a floating element will be formatted at the left margin of the parent element. The current block and sub sequent blocks will be floated on the right side of this floating element.

Below is a good example of a floating block element and a floating inline element:

 180 views

26⟩ Hot To Specify the Content Box Size of a Block Element?

If you want to control the size of the content box of a block element, you can use the "width" and "height" properties as shown below:

* {width: 300px} - Specifies the content box to be 300px wide.

* {height: 200px} - Specifies the content box to be 200px high.

The HTML and CSS document below shows you a good example of how to specify content box size of on a <P> tag:

 199 views