HTML Tag - GeeksforGeeks
Có thể bạn quan tâm
- Courses
- DSA to Development
- Machine Learning & Data Science
- Generative AI & ChatGPT
- Become AWS Certified
- DSA Courses
- Data Structure & Algorithm(C++/JAVA)
- Data Structure & Algorithm(Python)
- Data Structure & Algorithm(JavaScript)
- Programming Languages
- CPP
- Java
- Python
- JavaScript
- C
- All Courses
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Conditional Statements
- Python Loops
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Learn Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Interview Questions
- Core Java Interview Questions-Freshers
- Java Multithreading Interview Questions
- OOPs Interview Questions and Answers
- Java Exercises
- Java Quiz
- Java Quiz
- Core Java MCQ
- Java Projects
- Advance Java
- Spring Tutorial
- Spring Boot Tutorial
- Spring Boot Interview Questions
- Spring MVC Tutorial
- Spring MVC Interview Questions
- Hibernate Tutorial
- Hibernate Interview Questions
- Programming Languages
- JavaScript
- C++
- R Tutorial
- SQL
- PHP
- C#
- C
- Scala
- Perl
- Go Language
- Kotlin
- System Design
- System Design Tutorial
- Software Design Patterns
- System Design Roadmap
- Top 10 System Design Interview Questions and Answers
- Interview Corner
- Company Preparation
- Top Topics
- Practice Company Questions
- Interview Experiences
- Experienced Interviews
- Internship Interviews
- Competitive Programming
- Multiple Choice Quizzes
- Aptitude for Placements
- Computer Science Subjects
- Operating System
- DBMS
- Computer Networks
- Engineering Mathematics
- Computer Organization and Architecture
- Theory of Computation
- Compiler Design
- Digital Logic
- Software Engineering
- DevOps
- GIT
- AWS
- Docker
- Kubernetes
- Microsoft Azure Tutorial
- Google Cloud Platform
- Linux
- Linux Tutorial
- Linux Commands A-Z
- Linux Commands Cheatsheet
- File Permission Commands
- Linux System Administration
- Linux File System
- Linux Shell Scripting
- Linux Networking
- Linux Interview Questions
- Software Testing
- Software Testing Tutorial
- Software Engineering Tutorial
- Testing Interview Questions
- Jira
- Databases
- DBMS Tutorial
- SQL Tutorial
- PostgreSQL Tutorial
- MongoDB Tutorial
- SQL Interview Questions
- MySQL Interview Questions
- PL/SQL Interview Questions
- Android
- Android Tutorial
- Android Studio Tutorial
- Kotlin For Android
- Android Projects
- Android Interview Questions
- 6 Weeks of Android App Development
- Excel
- MS Excel Tutorial
- Introduction to MS Excel
- Data Analysis in Excel
- Basic Excel Formulas & Functions
- Data Analysis in Advanced Excel
- Workbooks
- Statistical Functions
- Data Visualization in Excel
- Pivot Tables in Excel
- Excel Spreadsheets in Python
- Basic Excel Shortcuts
- Mathematics
- Number System
- Algebra
- Linear Algebra
- Trigonometry
- Set Theory
- Statistics
- Probability
- Geometry
- Mensuration
- Logarithms
- Calculus
- Python Tutorial
- DSA
- Data Structures
- Arrays
- Matrix
- Strings
- Linked List
- Stack
- Queue
- Tree
- Heap
- Hashing
- Graph
- Set Data Structure
- Map Data Structure
- Advanced Data Structure
- Data Structures Tutorial
- Algorithms
- Analysis of Algorithms
- Design and Analysis of Algorithms
- Asymptotic Analysis
- Asymptotic Notations
- Worst, Average and Best Cases
- Searching Algorithms
- Linear Search
- Binary Search
- Searching Algorithms Tutorial
- Sorting Algorithms
- Selection Sort
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Counting Sort
- Radix Sort
- Bucket Sort
- Sorting Algorithms Tutorial
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- Analysis of Algorithms
- DSA Tutorial
- Practice
- All DSA Problems
- Problem of the Day
- Company Wise Coding Practice
- Amazon
- Microsoft
- Flipkart
- Explore All
- GfG SDE Sheet
- Practice Problems Difficulty Wise
- School
- Basic
- Easy
- Medium
- Hard
- Language Wise Coding Practice
- CPP
- Java
- Python
- Curated DSA Lists
- Beginner's DSA Sheet
- Top 50 Array Problems
- Top 50 String Problems
- Top 50 DP Problems
- Top 50 Graph Problems
- Top 50 Tree Problems
- Competitive Programming
- Company Wise SDE Sheets
- Facebook SDE Sheet
- Amazon SDE Sheet
- Apple SDE Sheet
- Netflix SDE Sheet
- Google SDE Sheet
- DSA Cheat Sheets
- SDE Sheet
- DSA Sheet for Beginners
- FAANG Coding Sheet
- Product-Based Coding Sheet
- Company-Wise Preparation Sheet
- Top Interview Questions
- Puzzles
- All Puzzles
- Top 100 Puzzles Asked In Interviews
- Top 20 Puzzles Commonly Asked During SDE Interviews
- Data Structures
- Data Science
- Python Tutorial
- R Tutorial
- Machine Learning
- Data Science using Python
- Data Science using R
- Data Science Packages
- Pandas Tutorial
- NumPy Tutorial
- Data Visualization
- Python Data Visualization Tutorial
- Data Visualization with R
- Data Analysis
- Data Analysis with Python
- Data Analysis with R
- Deep Learning
- NLP Tutorial
- Web Tech
- HTML Tutorial
- CSS Tutorial
- JavaScript Tutorial
- PHP Tutorial
- ReactJS Tutorial
- NodeJS Tutorial
- Bootstrap Tutorial
- Typescript
- Web Development Using Python
- Django
- Django Tutorial
- Django Projects
- Django Interview Questions
- Flask
- Flask Tutorial
- Flask Projects
- Flask Interview Questions
- Postman
- Github
- Django
- Cheat Sheets
- HTML Cheat Sheet
- CSS Cheat Sheet
- JavaScript Cheat Sheet
- React Cheat Sheet
- Angular Cheat Sheet
- jQuery Cheat Sheet
- Bootstrap Cheat Sheet
- Learn Complete Web Development
- HTML Tutorial
- HTML Exercises
- HTML Tags
- HTML Attributes
- Global Attributes
- Event Attributes
- HTML Interview Questions
- HTML DOM
- DOM Audio/Video
- HTML 5
- HTML Examples
- Color Picker
- A to Z Guide
- HTML Formatter
The pre tag in HTML defines a block of preformatted text, preserving spaces, line breaks, and tabs. It displays text in a fixed-width font, which can be styled using CSS. This tag is useful for displaying code, formatted text, and preserving text layout.
HTML <!DOCTYPE html> <html> <body> <pre> This is preformatted text. It preserves spaces and line breaks exactly. </pre> </body> </html>The <pre> tag is a powerful tool for preserving the exact formatting of text within a web page. By using the <pre> tag, along with related tags like <samp>, <var>, <code>, and <kbd>, you can effectively display preformatted text, sample outputs, variables, code snippets, and keyboard inputs in a visually appealing and semantically meaningful way. Customizing the appearance of the <pre> element with CSS further enhances its versatility and integration into your web design.
Note: The pre tag also supports the Event Attributes in HTML and Global Attributes in HTML.
Tag | Description |
---|---|
<samp> | Defines sample output from a computer program |
<var> | Defines a variable |
<code> | Defines a piece of computer code. |
<kbd> | Defines keyboard input |
Using CSS with the <pre> Tag
HTML <!DOCTYPE html> <html> <body> <pre style="font-family: Arial;color: #009900;margin: 25px;"> This is preformatted text. It preserves spaces and line breaks exactly. </pre> </body> </html>HTML <pre> Tag – FAQs
How does the <pre> tag handle whitespace?
The <pre> tag preserves all whitespace characters, including spaces, tabs, and line breaks. This is different from most HTML elements, which collapse multiple spaces into a single space and ignore line breaks.
Can I use the <pre> tag for displaying code?
Yes, the <pre> tag is commonly used to display code snippets in a readable format. It is often combined with the <code> tag for semantic purposes.
What is the difference between the <pre> tag and the <div> tag?
The key difference is that the <pre> tag preserves whitespace and line breaks exactly as they are in the source code, while the <div> tag does not. The <pre> tag is used for content where formatting needs to be maintained, while the <div> tag is used for general block-level content.
Can I include HTML elements inside a <pre> tag?
Yes, you can include other HTML elements like <b>, <i>, or <span> inside a <pre> tag. However, it’s most commonly used with text or code to maintain formatting. Be cautious with elements that could disrupt the formatting you’re trying to preserve.
Is the <pre> tag a block-level or inline-level element?
The <pre> tag is a block-level element, meaning it takes up the full width available and starts on a new line by default.
S
Shubrodeep Banerjee Follow Improve Previous Article HTML Phrase Tag Next Article HTML 5 <progress> TagSimilar Reads
How to remove margin introduced in pre tag in bootstrap 4? The problem is that whenever you apply margin space as per your margin value it will give you output. But in <pre> tag if you apply it by keeping any space then it will consider as margin. Because pre is acted vice versa, means as you have written inside the pre tag the output will be the same. Note: The examples will act same with the bootst 2 min read Which Characters Should Be Escaped Inside A "pre" tag? The <pre> tag defines pre-formatted text. Everything (generally, text and code snippets) in a <pre> tag element is displayed in a fixed-width font, and preserves both spaces and line breaks in them. In other words, if anyone wants to show their code snippets on a web page, they can simply enclose their code in the tag. But there are cer 3 min read How to wrap a text in a <pre> tag using CSS ? In this article, we will learn how to wrap a text in a <pre> tag. The <pre> tag is used to display the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. By default, the <pre> tag does not support the <pre> tag. In the case of rend 2 min read Which tag is used to represent progress of a task in HTML & how is it different from <meter> tag ? In this article, we will see which tag is used to represent the progress of a task in HTML. To represent the progress of a task, we will use the <progress> tag. This tag is used to represent the progress of a task. It is also defined how much work is done and how much is left. Syntax: <progress attributes...> </progress> Attribute 2 min read Is container tag same as the empty tag in HTML? If not, why ? In this article, we will see the container tag & empty tag in HTML, along with knowing how they're different from each other. The Container tag is not the same as the empty tag & these are two different categories of tags used in HTML. Container tag: This tag contains 3 parts, namely, the opening tag, content that will be displayed in the b 5 min read HTML | DOM Pre Object The DOM Pre Object is used to represent the HTML <pre> element. The pre element is accessed by getElementById().Properties: width: It is used to set or return the value of the width attribute of the pre element. Syntax: document.getElementById("ID"); Where “id” is the ID assigned to the “pre” tag.Example-1: C/C++ Code <!DOCTYPE html> 1 min read HTML | <pre> width Attribute The HTML <pre> width Attribute is used to specify the maximum number of characters per line. Note: The width Attribute is not supported by HTML5 Syntax: <pre width="number"> Attribute Values: number: It is used to set the maximum number of characters. Example: <!DOCTYPE html> <html> <head> <title> HTML pre width 1 min read Haml | HTML Pre-processor As its name suggests the pre-processor is the first stage of the whole compiling process it includes removing the comments, expanding the macros, the inclusion of the headers, etc. In HTML and CSS when it comes to writing it, It is a bit crucial as we have to do the same job again and again like closing the tab and repeating the same attribute for 3 min read HTML DOM Pre width Property The HTML DOM Pre width Property is used to set or return the value of the width attribute of the <pre> element. Syntax: It returns a pre width Property. preObject.widthIt is used to set the pre width property. preObject.width = "pixels/%"; Property Values: pixels: It sets the width of a predetermined text in terms of pixels.%: It sets the wid 2 min read How to specify a list of pre-defined options for input controls in HTML? Specify a list of pre-defined options for input controls by using the HTML list Attribute. A pre-defined option for input controls using HTML5's <datalist> element, allowing users to select from a predefined list while typing in an input field. Syntax: <input list="datalist_id"/>Example 1: The example below shows, the HTML form with an 2 min read Why <big> tag is not in HTML5 while <small> tag exists ? The <big> tag was discontinued in HTML5 while <small> tag is still in handy because <small> tag is frequently used to represent small prints like footnotes, copyright notices, comments etc. Many alternatives for <big> tag are already available such as <h1>, <h2> and so on. In HTML5 instead of using <big>, y 2 min read Explain the difference between head Tag and header Tag in HTML5 ? The <head> element is a container for metadata and is placed between the <html> and <body> tags. The <header> is for the main content section's introductory elements, like headings or logos and it mainly focuses on what appears at the top of the webpage. <head> ElementThe <head> element is part of the HTML docume 1 min read What is the difference between the <br> Tag and the <p> Tag ? The <br> tag is used to insert a line break, creating a new line within text or content. It doesn't have a closing tag and is a self-closing tag. On the other hand, the <p> tag defines a paragraph, separating blocks of text. It has an opening <p> and a closing </p> tag, allowing for the structured organization of text into p 2 min read Difference between <article> tag and <section> tag Both the tags are semantics in HTML 5. In this article, we will discuss about the <article> and <section> tag. Both the <article> and <section> tags are represented similarly but used for some meaning, that meaning is for the browsers and the developers. Both tags can replace each other as there will be no changes to the out 4 min read What purpose does a <script> tag serve inside of a <noscript> tag? Usage of NoScript tag: The tag defines alternate content that will be displayed if the user has disabled script or browser does not support script. It can be used inside both <head> and <body> tag. Syntax: <noscript> Contents... </noscript> Example: [GFGTABS] HTML <html> <head> <title>wbr Tag</title> 1 min read How to Create a Pre-Filled forms in Node.js ? Pre-Filled forms are those forms that are already filled with desired data. These are helpful when a user wants to update something like his profile, etc. We just create a folder and add a file, for example, index.js. To run this file you need to run the following command. node index.js Filename: SampleForm.ejs C/C++ Code <!DOCTYPE html& 2 min read Vue.js v-pre Directive The v-pre directive is a Vue.js directive used to skip compilation for this element and all its children. You can use this for displaying raw mustache tags. First, we will create a div element with id as app and let's apply the v-pre directive to an element. Further, we can use a heading element to show the data. Syntax: v-pre Parameters: This dire 1 min read How to specify that an option should be pre-selected when the page loads in HTML5? The <option> tag defines an option in a select list. The <option> tag is generally used with the value attribute to specify which value should be sent to the server for further processing. When a drop-down list is created using the <select> element, the first option or the first choice defined by the <option> tag is seen as 2 min read Semantic-UI Popup Pre-Existing Type Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to make your website look more amazing. It uses a class to add CSS to the elements. A Popup displays extra facts about the element to the user when he/she hovers over it. Semantic UI 2 min read Mongoose Schema.prototype.pre() API The Mongoose Schema API pre() method is used to add a pre-hook to the mongoose Schema methods and can be used to perform pre Schema method operations. Syntax: Schema.prototype.pre(methodName, options, callback) Parameters: It accepts the following parameters as mentioned above and described below: methodName: It denotes the name of the Schema metho 3 min read Mongoose Query.prototype.pre() API The Mongoose Query API pre() method is used to add a pre-middleware to the mongoose query instance, which can be used in performing pre-query operations. Syntax: Query.prototype.pre(fn) Parameters: It accepts the following parameters as mentioned above and described below: fn: It is a middleware function that is used to perform pre-query operations 2 min read Less.js @plugin At-Rules Pre-Loaded Plugins Less.js is a powerful preprocessor that extends the functionality of CSS by adding programming constructs, such as variables, mixins, and functions. One of the key features of Less.js is the ability to create and use plugins that can be added to a Less.js stylesheet to provide additional functionality. One type of plugin that is particularly useful 3 min read How To Fix Git Error: Pre-Receive Hook Declined? When working with Git repositories, you may encounter an error message that says "Pre-receive hook declined." This error occurs when a pre-receive hook, a type of server-side Git hook, rejects your push. Pre-receive hooks are scripts that run on the server before the push is accepted, and they are often used to enforce rules about commits, branches 3 min read JavaScript Program to Create an Array with a Specific Length and Pre-filled Values In JavaScript, we can create an array with a specific length and pre-filled values using various approaches. This can be useful when we need to initialize an array with default or placeholder values before populating it with actual data. Table of Content Method 1: Using the Array() Constructor and fill() MethodMethod 2: Using a Loop to Initialize V 3 min read Different forms of Pre-rendering in NextJS Next JS is a React-based full-stack framework that enables functionalities like pre-rendering of web pages. Unlike traditional react app where the entire app is loaded on the client, Next JS allows the web page to be rendered on the server, which is great for performance and SEO. You can learn more about Next Js here. Next.js supports two main form 4 min read How to pre-select an input element when the page loads in HTML5? In this article, we are going to pre-select an input element when the page loads i.e. the user doesn't have to click the first text box to start writing on it. When the page is loaded the input is to be pre-selected and the user can start typing directly. This can be done by using the autofocus attribute. It is a boolean attribute that brings an el 1 min read How to pre-compile LESS into CSS ? In this article, we will discuss how to pre-compile the LESS file into a CSS file & will understand its implementation through the example. Introduction: LESS is a simple CSS pre-processor that makes it possible to create manageable, customizable, and reusable style sheets for websites. LESS is a backward-compatible language extension for CSS a 3 min read Pre-request and Post-request scripts in Postman Postman is a powerful tool for testing APIs, and its pre-request and post-request scripts allow you to customize requests and responses. it is an API(utility programming interface) development device that enables construction, taking a look at and altering APIs. It could make numerous varieties of HTTP requests(GET, POST, PUT, PATCH), store environ 4 min read What are pre-request scripts in Postman, and how are they used? Postman is an API(application programming interface) development tool which helps to build, test and modify APIs. It has the ability to make various types of HTTP requests(GET, POST, PUT, PATCH), save environments for later use, converting the API to code for various languages(like JavaScript, Python). In this article, we will learn What are pre-re 2 min read How to Change a Span to Look Like a Pre with CSS? To make a <span> look like a <pre> element with CSS, you need to mimic the behavior of whitespace and styling associated with <pre>. 1. Using Inline CSS Inline CSS is a styling method for HTML pages using the style attribute of an HTML element. Using Inline CSS is not considered a good practice but it depends on the size of the pr 2 min read Article Tags :- HTML
- Web Technologies
- HTML-Tags
What kind of Experience do you want to share?
Interview Experiences Admission Experiences Career Journeys Work Experiences Campus Experiences Competitive Exam ExperiencesTừ khóa » Html5 Text Tag
-
List Of HTML5 Tags/Elements - Tutorial Republic
-
HTML Text Formatting - W3Schools
-
HTML Elements Reference - HTML: HyperText Markup Language
-
HTML Text Tag - Javatpoint
-
HTML Tags For Text - Flavio Copes
-
HTML5 - Tags Reference - Tutorialspoint
-
HTML: Tag - TechOnTheNet
-
Alignment, Font Styles, And Horizontal Rules In HTML Documents
-
WebD2: Common HTML Tags - University Of Washington
-
Playing With HTML Paragraphs: Let's Show You Different Formatting ...
-
In HTML, How Can I Change The Size Of Text On My Web Page? - IU KB
-
What Is The Tag To Underline Text In HTML 5? - Quora
-
How To Bold, Italicize & Format Text In HTML - HubSpot Blog
-
HTML Font Size – How To Change Text Size With An HTML Tag