Text decoration in HTML used for decorating the text in different ways. text-decoration is the property used for text decoration. text-decoration property takes underline, overline, line-through, underline overline values to decorate the text in different ways.
Real-Time Example: Text-decoration overline, underline, line-through values are used generating captchas while confirming the login user is whether human or robot. Because if lines on top of the text can’t be recognized by the robot perfectly.
Types:
- text-decoration: none;
- text-decoration: overline;
- text-decoration: line-through;
- text-decoration: underline;
How does text-decoration work in HTML?
Text-decoration property works based on none, overline, line-through and underline
1. None
Syntax:
text-decoration: none;
Explanation: It will not give any decoration to the text. It is just like a normal text.
2. Overline
Syntax:
text-decoration: overline;
Explanation: It will give a line on top of the text with a 1px size.
3. Line-through
Syntax:
text-decoration: line-through;
Explanation: It will give the line from the middle of the text with 1px size.
4. Underline
Syntax:
text-decoration: underline;
Explanation: It will give a line at the bottom of the text with a 1px size.
5. Blink
Syntax:
text-decoration: blink;
Explanation: It will make the text blinking with different colors from opacity 0% to 100%.
Note: The recent browser’s blink feature is deprecated. Now it is not used at all.Text-decoration property can also make overline, line-through, underline with different styles other than default styles like dotted, wavy, solid, groove, etc., with color. You can see the below syntaxes.
Syntax:
text-decoration: underline dotted red;
Examples of HTML Text Decoration
Below are the examples for the HTML text decoration:
Example #1 – None
Code:
<style> h1 { text-align:center; color:green; } .none { text-decoration: none; font-size:20px; } } </style> <h1 id="Demo-for-text-decoration-none">Demo for text-decoration:none</h1> <p class="none"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in the development of back end features in Spring MVC with Hibernate. Developed importing models and logic in the Office Note app to store spreadsheet data and deployed to host. </p>
Output:
Explanation: As you can see, text-decoration: none can’t give any line decoration with the paragraph text.
Example #2 – Underline
Code:
<style> h1 { text-align:center; color:green; } .underline { text-decoration: underline; font-size:20px; } } </style> <h1 id="Demo-for-text-decoration-underline">Demo for text-decoration:underline</h1> <p class="underline"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p>
Output:
Explanation: As you can see, text-decoration: underline gives line below of the text.
Example #3 – Overline
Text-decoration: overline example:
Code:
<style> h1 { text-align:center; color:green; } .overline{ text-decoration: overline; font-size:20px; } } </style> <h1 id="Demo-for-text-decoration-overline">Demo for text-decoration:overline</h1> <p class="overline"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p>
Output:
Explanation: As you can see, text-decoration: overline gives line above the text.
Example #4 – Line-through
Text-decoration:line-through example:
Code:
<style> h1 { text-align:center; color:green; } .through { text-decoration: line-through; font-size:20px; } } </style> <h1 id="Demo-for-text-decoration-line-through">Demo for text-decoration:line-through</h1> <p class="through"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p>
Output:
Explanation: As you can see, text-decoration: line-through gives line from the middle of the text.
Example #5
Text-decoration with solid, double, wavy with an underline, line-through, overline example:
Code:
<style> h1 { text-align:center; color:green; } .p1 { text-decoration:solid overline brown; font-size:18px; } .p2 { text-decoration:double line-through blue; font-size:18px; } .p3 { text-decoration:wavy underline red; font-size:18px; } } </style> <h1 id="Demo-for-text-decoration-solid-overline-brown">Demo for text-decoration:solid overline brown</h1> <p class="p1"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p> <h1 id="Demo-for-text-decoration-double-line-through-blue">Demo for text-decoration:double line-through blue</h1> <p class="p2"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p> <h1 id="Demo-for-text-decoration-wavy-underline-red">Demo for text-decoration:wavy underline red</h1> <p class="p3"> Executed and contributed to full-stack web development projects, with an emphasis on front end features, browser manipulation, and cross-browser compatibility. Wrote templates and front-end code for ECM app to meet WebTop application compatibility. Assisted in development of back end features in Spring MVC with Hibernate. Developed importing models and logic in Office Note app to store spreadsheet data and deployed to host. </p>
Output:
Explanation: As you can see, the first paragraph has a solid overline, the second paragraph has double line-through and the third paragraph with wavy underline text-decoration styles.
Conclusion
Text decoration can be styled by overline, underline, line-through property values and also different line styles with any color.
The above is the detailed content of HTML Text Decoration. For more information, please follow other related articles on the PHP Chinese website!

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version
Visual web development tools
