HTML - tags - code tag

revision:


Content

"code" tag : displays content as being computer code syntax some examples


"code" tag : displays content as being computer code

top

The <code> HTML element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code By default, the content text is displayed using the browser's default monospace font.

To represent multiple lines of code, wrap the <code> element within a <pre> element. The <code> element by itself only represents a single phrase of code or line of code.

The <code> tag is not depreciated. However, a CSS rule can be defined for the code selector to override the browser's default font face. Preferences set by the user might take precedence over the specified CSS.

Attributes: the <code> tag includes the global attributes.


syntax

top

: <code> . . . </code>

some examples

top

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The HTML button tag defines a clickable button.

The CSS background-color property defines the background color of an element.

code:
                <div>
                    <p class="example">The <code>push()</code> method adds one or more 
                    elements to the end of an array and returns the new length of the array.</p>
                    <p class="example">The HTML <code>button</code> tag defines a clickable
                    button.</p>
                    <p class="example">The CSS <code>background-color</code> property defines
                    the background color of an element.</p>
                </div>
            
                

example

body { color: yellow; font-size: 16px; line-height: 1.5; }
                

example: # Display the sumprogram adds two numbers

nu1 = 2.5 nu2 = 5.3 sum = float(nu1) + float(nu2) print('The sum of two num {0} and {1} is {2}'.format(nu1, nu2, sum))

without the <pre> tag

Here's the basic code for creating a table in HTML:

<table> <tr> <td></td> <td></td> </tr> </table>

with the <pre> tag

Here's the basic code for creating a table in HTML:

                        
                        <table>
                            <tr>
                                <td></td>
                                <td></td>
                            </tr>
                        </table>