CSS/C2/Display-Property-in-CSS/English
Title of the script: Display property in CSS
Author: Neha Solanki
Domain Reviewer: Ankita Maske, Om Prakash Soni
Novice Reviewer: Madhuri Ganapathi
Keywords: CSS, HTML, Web Page, Web Design, Web Technology, Video Tutorial, Spoken Tutorial, CSS Property, CSS Display, Block Level Element, Inline Level Element
Visual Cue | Narration |
Slide: Title | Welcome to the spoken tutorial on “Display property in CSS” |
Slide: Learning Objectives | In this tutorial we will learn about:
|
Slide:
System Requirements |
This tutorial is recorded using
However you may use any other editor or browser of your choice. |
Slide: Prerequisite | To practise this tutorial, you should know to use HTML and CSS
If not, please go through the HTML and CSS tutorials on this website. |
Slide: Code Files | The files used in this tutorial are available in the Code Files link on this tutorial page.
Please download and extract them. Make a copy and then use them while practising. |
Slide: Display |
|
Slide: Display |
Let us understand these one by one. |
Slide: Block |
|
Slide: Block-level element
<div> <header> <h1> to <h6> <p> <form> |
These are some elements which have a default block value: |
Slide: Inline |
|
Slide: Inline-level element | The Inline-level element
|
Slide: Inline-level element
<span> <a> <img> |
These are some elements which have default inline value:
Let us try with some examples. |
Open my-css folder | Go to the practice folder my-css. |
Open mystyle.css | Let’s open the file mystyle.css in a text editor.
The same is available in the Code files link for practice. I have already opened it in the gedit Text Editor. |
Point to Mypage.html in my-css folder | Switch to the my-css folder
For this demonstration, I’m using the file Mypage.html. The same is available in the Code files link for practice. |
Open Mypage.html in firefox | Now open the file Mypage.html in a web browser.
The webpage opens. |
Switch to mystyle.css | Switch to the mystyle.css file. |
[gedit - mystyle.css]
Type: #item1{
#item2{
|
Now let’s create two elements using an id selector.
Next to the div tag, type the code as shown. |
[gedit - mystyle.css] Highlight:
height: 200px; width: 150px; background: lightpink; |
In both the cases I have set the height, width and background. |
Highlight:
display: block; |
For item1 I have set the value for the display property to block. |
Highlight:
display: inline; |
For item2 I have set the value for the display property to inline. |
Press Ctrl + S | Save the file. |
Switch to the my-css | Switch to the my-css folder. |
Open Mypage.html in gedit | Open the file Mypage.html in the text editor. |
[gedit - Mypage.html]Type:
<p id = "item1"> Fruits and vegetables provide essential vitamins and minerals to the body </p> <p id = "item2"> Fruits and vegetables provide essential vitamins and minerals to the body </p> |
Now add these items to the paragraphs.
Inside the body tag, next to the div closing tag, type the code as shown. |
Press Ctrl + S | Save the file. |
Switch to firefox | Switch to the browser and refresh the page. |
[Firefox]
Highlight the paragraph |
Observe the output.
We can see two new paragraphs. The first paragraph is in blocks with the mentioned height and width. While the second paragraph is in inline and it ignores the mentioned height and width. |
Switch to mystyle.css | Switch to the mystyle.css file. |
[gedit - mystyle.css]
Delete: display: inline; |
Now I will remove the display property from item2.
Inside #item2, delete the code as shown. |
Press Ctrl + S | Save the file. |
Switch to firefox | Switch to the browser and refresh the page. |
[Firefox]
Highlight the paragraph |
Observe the output.
Now the second paragraph is also inside the block. This is because by default the display property value of a paragraph is block. |
Slide: None |
Let us try this. |
Switch to mystyle.css | Switch to the mystyle.css file. |
[gedit - mystyle.css]
#item1: Update: display: none; #item2: Type: display: none; |
Now I will set the display value to none in item1 and item2.
In the #item1 and #item2, update the code as shown. |
Press Ctrl + S | Save the file. |
Switch to firefox | Switch to the browser and refresh the page. |
[Firefox]
Highlight the paragraph |
Observe the output.
Both the paragraphs are not displayed now. |
Switch to mystyle.css
Ctrl + Z Ctrl + S |
Switch to the mystyle.css file
Press Ctrl + Z keys repeatedly to undo all the changes which we have made in this file. Save the file. |
Switch to Mypage.html
Ctrl + Z Ctrl + S |
Switch to the Mypage.html file
Press Ctrl + Z keys repeatedly to undo all the changes which we have done in this file. Save the file. |
Only narration | With this we have come to the end of this tutorial.
Let us summarize. |
Slide: Summary | In this tutorial, we have learnt about:
|
Slide: Assignment | As an assignment
|
Slide: Assignment |
|
Slide:
About Spoken Tutorial project |
The video at the following link summarises the Spoken Tutorial project.
Please download and watch it. |
Slide: Spoken Tutorial Workshops | The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us. |
Slide: Forum | Please post your timed queries on this forum. |
Slide: Acknowledgement | Spoken Tutorial project is funded by Ministry of Education (MoE), Govt. of India. |
Slide: Thanks | The script for this tutorial is contributed by Neha Solanki
and this is Madhuri Ganapathi from IIT Bombay. Thank you for watching. |