Write text with different textBasline alignment:
JavaScript:
The textBaseline attribute is used to vertically align text on the canvas.
Imagine there are lines running through the letters:
The fillText() and strokeText() methods will use these lines when positioning the text.
The different attributevalues will produce this output:
| Default value: | alphabetic |
|---|---|
| JavaScript syntax: | context.textBaseline="middle"; |
![]()
The textBaseline attribute is supported in all major browsers, with some differences, especially when using the "hanging" and the "ideographic" values.
| Values | Description | Play it |
|---|---|---|
| alphabetic | Aligns the text vertically at the alphabetical line (see illustration above) | Play it » |
| bottom | Aligns the text vertically at the bottom line (see illustration above) | Play it » |
| hanging | Aligns the text vertically at the hanging-line (see illustration above) | Play it » |
| ideographic | Aligns the text vertically at the ideographical line (see illustration above) | Play it » |
| middle | Aligns the text vertically at the top line (see illustration above) | Play it » |
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $3.98 Unlimited Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| XML Editor - Free Trial! |
| FREE Website BUILDER |
| Best Website Templates Top CSS Templates |
| CREATE HTML Websites |
| EASY WEBSITE BUILDER |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|