HTML Text Decoration
Sep 04, 2024 pm 04:40 PMText 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:
<!DOCTYPE html> <html> <head> <style> h1 { text-align:center; color:green; } .none { text-decoration: none; font-size:20px; } } </style> </head> <body> <h1>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> </body> </html>
Output:
Explanation:?As you can see, text-decoration: none can’t give any line decoration with the paragraph text.
Example #2 –?Underline
Code:
<!DOCTYPE html> <html> <head> <style> h1 { text-align:center; color:green; } .underline { text-decoration: underline; font-size:20px; } } </style> </head> <body> <h1>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> </body> </html>
Output:
Explanation:?As you can see, text-decoration: underline gives line below of the text.
Example #3 –?Overline
Text-decoration: overline example:
Code:
<!DOCTYPE html> <html> <head> <style> h1 { text-align:center; color:green; } .overline{ text-decoration: overline; font-size:20px; } } </style> </head> <body> <h1>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> </body> </html>
Output:
Explanation:?As you can see, text-decoration: overline gives line above the text.
Example #4 –?Line-through
Text-decoration:line-through example:
Code:
<!DOCTYPE html> <html> <head> <style> h1 { text-align:center; color:green; } .through { text-decoration: line-through; font-size:20px; } } </style> </head> <body> <h1>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> </body> </html>
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:
<!DOCTYPE html> <html> <head> <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> </head> <body> <h1>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>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>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> </body> </html>
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!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams.

It is a block-level element, suitable for layout; it is an inline element, suitable for wrapping text content. 1. Exclusively occupy a line, width, height and margins can be set, which are often used in structural layout; 2. No line breaks, the size is determined by the content, and is suitable for local text styles or dynamic operations; 3. When choosing, it should be judged based on whether the content needs independent space; 4. It cannot be nested and is not suitable for layout; 5. Priority is given to the use of semantic labels to improve structural clarity and accessibility.

Metadata in HTMLhead is crucial for SEO, social sharing, and browser behavior. 1. Set the page title and description, use and keep it concise and unique; 2. Add OpenGraph and Twitter card information to optimize social sharing effects, pay attention to the image size and use debugging tools to test; 3. Define the character set and viewport settings to ensure multi-language support is adapted to the mobile terminal; 4. Optional tags such as author copyright, robots control and canonical prevent duplicate content should also be configured reasonably.

It is more convenient to submit form data using HTML5's FormData API. 1. It can automatically collect form fields with name attribute or manually add data; 2. It supports submission in multipart/form-data format through fetch or XMLHttpRequest, which is suitable for file upload; 3. When processing files, you only need to append the file to FormData and send a request; 4. Note that the same name field will be overwritten, and JSON conversion and no nesting structure need to be handled.

MSE (MediaSourceExtensions) is part of the W3C standard, allowing JavaScript to dynamically build media streams, thus enabling advanced video playback capabilities. It manages media sources through MediaSource, stores data from SourceBuffer, and represents the buffering time range through TimeRanges, allowing the browser to dynamically load and decode video clips. The process of using MSE includes: ① Create a MediaSource instance; ② Bind it to an element; ③ Add SourceBuffer to receive data in a specific format; ④ Get segmented data through fetch() and append it to the buffer. Common precautions include: ① Format compatibility issues; ② Time stamp pair

HTML5 tags can directly implement web page progress bars. 1. The basic usage is to set the value and max attributes, such as displaying 30% progress; 2. If the progress is unknown, the value can be omitted and only set max, which means an uncertain state; 3. You can customize the style through CSS, and browser compatibility needs to be handled; 4. It is often used in scenarios such as uploading files, form progress, and game loading; 5. Pay attention to avoid using it when the task is completed too quickly, and consider the compatibility issues of the old version of IE.

HTML5introducednewinputtypesthatenhanceformfunctionalityanduserexperiencebyimprovingvalidation,UI,andmobilekeyboardlayouts.1.emailvalidatesemailaddressesandsupportsmultipleentries.2.urlchecksforvalidwebaddressesandtriggersURL-optimizedkeyboards.3.num

class, id, style, data-, and title are the most commonly used global attributes in HTML. class is used to specify one or more class names to facilitate style setting and JavaScript operations; id provides unique identifiers for elements, suitable for anchor jumps and JavaScript control; style allows for inline styles to be added, suitable for temporary debugging but not recommended for large-scale use; data-properties are used to store custom data, which is convenient for front-end and back-end interaction; title is used to add mouseover prompts, but its style and behavior are limited by the browser. Reasonable selection of these attributes can improve development efficiency and user experience.
