我们有什么方法可以在HTML页面中显示HTML代码

时间:2015-03-06 11:21:13

标签: javascript html css twitter-bootstrap modal-dialog

我有一个页面,我必须显示一些HTMl代码。 该代码不是同一个HTML页面,而是其他代码。

我该怎么做?有办法吗?像stackoverflow这样的东西,如果我们单击代码按钮并缩进4个空格,我们可以编写显示原样的代码。 怎么做??

我想要显示的实际代码:

<!--Modal design for 7th Form Try popup modal-->
        <div id="tallModal7" class="modal modal-wide fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">Registration Form</h4>
                    </div>
                    <div class="modal-body">
                        <form action = "#" method = "get">
                            <div class="has-success">
                            <label for = "name">Name:</label>
                            <input type="text"  class="form-control" placeholder="Enter your Full Name" id = "name"  required>
                            </div><br>
                            <div class="has-success">
                            <label for = "dob">DOB:</label>
                            <input type="date"   class="form-control" placeholder="DOB" id = "dob"  required>
                            </div><br>
                            <label for = "email">Email ID:</label>
                            <div class="has-success">
                            <input type="email" class="form-control" placeholder="Enter your Email" id = "email" required>
                            </div><br>
                            <label for = "city">City:</label>
                            <div class="has-success" >
                            <input type="text"  class="form-control" placeholder="Enter your city name" id = "city" required>
                            </div><br>
                            <label for = "contact">Contact Number:</label>
                            <div class="has-success" >
                            <input type="number"  class="form-control" placeholder="Enter your contact number"  id = "contact" required>
                            </div><br>
                        </form>
                    <div class="modal-footer">
                        <button type = "submit" class="btn btn-primary" onclick = "thankyou()" data-dismiss = "modal">Submit</button>
                        <button type = "reset" data-dismiss = "modal" class="btn btn-primary">Close</button>
                    </div>

                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!--It ends here-->

1 个答案:

答案 0 :(得分:0)

您可以使用各自的html字符代码替换开始和结束标记,然后将其包装在“pre”和“code”标记内。

您可以替换:

& with &amp;
< with &lt;
> with &gt;