Do More with the Text Editor
The text editor on your site is a powerful HTML editor. Along with accessing various styles through the toolbar, you can add and edit HTML directly.
The text area allows a subset of HTML tags and classes so that we can more easily maintain the usability and accessibility of your site.
Edit HTML source code
The text editor creates HTML code from the styles and text that you add to the editor. There may be times you'll want to edit the HTML directly. Here's how to view and edit the HTML source code.
- Click Edit to begin editing your page
- Within the Body or Text Area toolbar of the WYSIWYG editor, click Source.
- This will bring up a code editor that allows you to directly edit the HTML.
- When you're done you can either click Source to return to the text editor or simply click Save.
Format text as code
Sometimes you need to indicate that some of your text is code. There are two styles for formatting code. One will insert a code block, the other will format the text in a monospaced font. Both of these options can be selected from the Text Area toolbar.
Insert code block
This is best for formatting a whole chunk of code, but is not yet formatted for Stanford Sites. Stay tuned!
Format text as code
This is best for formatting a small snippet of text.
- Highlight the text you wish to format.
- Select Code
Example: <h1>Page Title </h1>
Call out other languages with "lang
"
If the text in your website uses multiple languages, you'll want to indicate what language is being displayed. The lang
attribute is used to identify chunks of text in a language that is different from the document’s primary language. For example, this page you are reading is written in English and screen readers will announce the text in English. The lang
attribute identifies the language of text content and informs the screen reader to announce text in the correct language.
Given this text in French:
Using inspect through the browser, you can see the lang
attribute in action.
To add the lang
attribute in the WYSIWYG,
- click on the Source button
- find the non-English text, in this example it's French
- within the
<p>
tag addlang="fr"
This will work with other HTML elements, such as <span>
, as well.
If you have multiple non-English paragraphs on a page, add the lang
attribute to all the <p>
tags
Lang
attribute resources
- More on the
lang
attribute: Using the HTML lang attribute - Find a language tag: Language subtag lookup
Call out abbreviations with <abbr>
When using a new or unfamiliar abbreviation or acronym, use the abbreviation element <abbr>
to provide a full expansion of the term in plain text on first use, along with the <abbr>
to mark up the abbreviation. This informs the user what the abbreviation or acronym means. Learn more about using <abbr>.
Given this HTML:
You will see:
To add an <abbr> element in the WYSIWYG:
- click on the Source button to edit the HTML
- find the abbreviation
- Surround the acronym with <abbr> before and </abbr> after