Update:- New tutorial added in HTML section. How to Create Responsive Login Page in HTML without Bootstrap?
Update:- New tutorial added in HTML section. How to Create Responsive Login Page in HTML without Bootstrap?
In this tutorial you will learn how we can show our HTML, C#, Java, C language etc. code on webpage.
I tried to find the solution of this problem, but I didn’t found any helpful solution on the internet. Here you will get your problem solution in easy way.
If you found any difficulty and mistakes in this tutorial please let me know by posting comment in comment box or send me message in contact us form.
The tag that is use to show the coding of html, java c etc on page are given below.
The <pre> .. </pre> tag is use to display or show the all language coding as same on HTML webpage. We will use HTML <pre> .. </pre> tag to display or show the coding on our HTML webpage. With the help of <pre> .. </pre> tag we can do it.
In HTML <pre> .. </pre> tag we write or paste our HTML, C#, Java, C etc. code. It will show or display same code as you written or pasted in <pre> .. </pre> tag.
<html> <head> <title>Exaple of pre tag.</title> </head> <body> <h1>Campuslife</h1> </body> </html>
Open your Notepad or Adobe Dreamweaver or any other HTML editor. I am using Adobe Dreamweaver. I am suggesting to you use Notepad for better practice.
To open the Notepad press window + r and type notepad, then press enter. Or you can find in start menu.
Start Menu → All programs → Accessories → Notepad.
Let’s start working with <pre> .. </pre> tag.
In <pre> .. </pre> tag we show the HTML angle brackets (< >) tags with help of < (< less then angle bracket) and > (> greater then angle bracket).
Let suppose you want to display a <html> tag in <pre> .. </pre> tag then we will use above angle brackets.
<pre> <html> </pre>
<html>
I hope now you have understood the concept of <pre> .. </pre> tag. Now our beginning level has been finished.
Now we will work on our different language coding like html, c#, java, etc. which we want to show on webpage.
First create <pre> .. </pre> tag and copy the below html code and paste it in between <pre> .. </pre> tag.
You will see the HTML angle brackets I replaced with < and > angle brackets because we want to display or show it on webpage.
<html> <head> <title>Welcome to campuslife.</title> </head> <body> <h1>Campuslife Wesbite</h1> <h2>My first page.</h2> <p> Campuslife is a free learning source website for users. <p> </body> </html>
Now we will apply the css to above HTML code. First create the class of your <pre> .. </pre> tag like below.
<pre class="mycode"> .. </pre>
I have created mycode class for my <pre> .. </pre> tag.
Now apply the CSS to your <pre> .. </pre> tag for better presentation. First create CSS <style> .. </style> tag in between <head> .. </head> tag like below.
<head> <style type="text/css"> all css code come here.... </style> </head>
Now copy the below CSS code and paste it in between <style> .. </style> tag.
.mycode{ display: block; padding: 3px 3px 2px; font-size: 14px; line-height: 20px; width: 100%; background-color: #333; font-family: arial; color: #f7f7f7; font-weight: bold; }
Now save your file with any name with .html extension. Like mypage.html. After saving the file open the file by double click on it. It will be open in browser. Now you will see your coding on webpage same as in editor it is.
<html> <head> <title>Welcome to campuslife.</title> </head> <body> <h1>Campuslife Wesbite</h1> <h2>My first page.</h2> <p> Campuslife is a free learning source website for users. <p> </body> </html>