7.1. Working with HTML Components

7.1.1. HTML Component Overview

HTML, or HyperText Markup Language, is the standard markup language used to create web pages. Web browsers present HTML code in a more readable format.

When students see text and images in your course, they are seeing HTML code that is formatted and presented by their browsers. For more information about HTML, see Wikipedia.

HTML components are the basic building blocks of your course content. You use HTML components to add and format text, links, images, and more. You can choose to create HTML components directly in HTML code, or using a visual editor that hides the HTML code details, as described below.

For more information, see the following topics:

Note

Review Developing Your Course and Best Practices for HTML Markup before you start working with HTML components.

To add an instant hangout to an HTML component, see Google Instant Hangout Tool.

7.1.2. Options for Editing HTML Components

You can work with HTML in two ways:

  • The Visual Editor

    With the visual editor you can create, edit, and format content in a word processing-like interface, without using HTML code directly. With the visual editor, you can more easily format your content, and add links and images. The visual editor provides access to HTML code so you can make small changes to formatting, if required. However, the HTML view in the visual editor does not provide the detailed control you can get with the raw HTML editor, and does not support custom formatting or scripts.

  • The Raw HTML Editor

    With the raw HTML Editor, you work directly with HTML code. If you need to use custom formatting or scripts in your content, you should use the raw HTML editor.

7.1.2.1. Set the Editor for an HTML Component

You set the editor for an HTML component in the Settings tab:

The Editor selection drop-down list in the HTML Component Settings tab

Select Visual or Raw. When you change the editor, you must click Save and re-open the component to begin using the new editor.

Warning

If you work with content in the raw HTML editor, then switch to the visual editor, you may lose custom HTML that you created. Therefore, it is recommended that you start by using the visual editor, then switch to the raw HTML editor when you need to create custom HTML.

7.1.3. The Visual Editor

The visual editor provides a “what you see is what you get” (WYSIWYG) interface that allows you to format text by clicking the formatting buttons at the top of the editor.

Image of the HTML component editor

Note

The visual editor is not available for course handouts.

The following image shows call-outs for the editing options and is followed by descriptions.

Image of the HTML editor, with call-outs for formatting buttons
  1. Choose a formatting style for the selected paragraph, such as heading 1, heading 2, or paragraph.
  2. Choose a font family for selected text, such as Arial, Courier New, or Times New Roman.
  3. Format selected text in bold.
  4. Format selected text in italics.
  5. Underline selected text.
  6. Apply a color to the selected text.
  7. Format selected text as code.
  8. Create a bulleted list.
  9. Create a numbered list.
  10. Decrease and increased the indentation of the selected paragraph.
  11. Format the selected paragraph as a blockquote.
  12. Create a link from the selected text. See Add a Link in an HTML Component.
  13. Delete the current link.
  14. Insert an image at the cursor. See Add an Image to an HTML Component.
  15. Work with HTML source code, described below.

7.1.3.1. Work with HTML code in the Visual editor

To work with HTML source code for the content you create in the visual editor, click HTML in the editor toolbar. The HTML source code editor opens:

Image of the HTML source code editor

Edit the HTML code as needed.

You should not add custom styles or scripts in the HTML code view in the visual editor. Use the raw HTML editor instead.

Click OK to close the source code editor and apply your changes in the visual editor. The visual editor then attempts to ensure the underlying HTML code is valid; for example, if you do not close a paragraph tag, the editor will close it for you.

Warning

Clicking OK in the source code editor does not save your changes to the HTML component. You return to the component editor, where your changes are applied. You must then also click Save to save your changes and close the component. If you click Cancel, the changes you made in the HTML source code are lost.

7.1.4. The Raw HTML Editor

When you select the raw editor for the HTML component, you edit your content in a text editor:

The raw HTML editor

You must enter valid HTML. The raw HTML editor does not validate your HTML code. Therefore you should thoroughly test the HTML content in your course.

7.1.5. HTML Component Templates

When you create a new HTML component, you select from a list of templates:

The list of HTML Component templates

The raw HTML template is set to use the raw HTML editor. All other templates use the visual editor.

For any HTML component, you can change the editor, regardless of the template used to create the component. See Set the Editor for an HTML Component.

7.1.6. Create an HTML Component

To create an HTML component:

  1. Under Add New Component, click HTML.
Image of adding a new HTML component
  1. Select the template.

    The rest of these instructions assume you selected Text, which creates an empty component with the visual editor selected.

    An empty component appears at the bottom of the unit.

Image of an empty HTML component
  1. In the component, click Edit.

    The HTML component opens in the visual editor.

Image of the HTML component editor
  1. Enter and format your content. You can Work with HTML code in the Visual editor if needed.

  2. Enter a display name (the name that you want students to see). To do this, click Settings in the upper-right corner of the component editor, and then enter text in the Display Name field.

    To return to the text editor, click Editor in the upper-right corner.

  3. Click Save to save the HTML component.

When using the visual editor, you can also:

7.1.8. Add an Image to an HTML Component

When using the visual editor, you can add any image that you have uploaded for the course to an HTML component. For more information about uploading images, see Adding Files to a Course.

Note

Review Best Practices for Describing Images before you add images to HTML components.

To add an image, you’ll need the URL of the image that you uploaded to the course. You’ll then create a link to the image in the HTML component.

  1. On the Files & Uploads page, copy the Embed URL of the image that you want.
Image of the Files & Upload page with the Embed URL for the image circled

Note

You must use the Embed URL to add the image, not the External URL.

  1. Click the image icon in the toolbar.

  2. In the Insert image dialog box, enter the following in the Source field.

    /static/FileName.type

    Make sure to include both forward slashes (/).

    Image of the Insert image dialog box with a reference to a file
  1. Enter alternative text in the Image description field. This text becomes the value of the alt attribute in HTML and is required for your course to be fully accessible. See Best Practices for Describing Images for more information.

  2. As needed, customize the image dimensions. Keep Constrain proportions checked to ensure the image keeps the same width and height proportions.

  3. To change the spacing and border of the image, click the Advanced tab.

    Image of the Insert image dialog box Advanced tab
  4. Enter the Vertical space, Horizontal space, and Border as needed. The values you enter are automatically added to the Style field.

  5. Click OK to insert the image in the HTML component.

  6. Save the HTML component and test the image.

7.1.9. Import LaTeX Code into an HTML Component

You can import LaTeX code into an HTML component. You might do this, for example, if you want to create “beautiful math” such as the following.

Image of math formulas created with LaTeX

Warning

The LaTeX processor that Studio uses to convert LaTeX code to XML is a third- party tool. We recommend that you use this feature with caution. If you do use it, make sure to work with your Program Manager.

This feature is not enabled by default. To enable it, you have to change the advanced settings in your course.

To create an HTML component that contains LaTeX code:

  1. Enable the policy key in your course.
    1. In Studio, click Settings, and then click Advanced Settings.
    2. In the field for the Enable LaTeX Compiler policy key, change false to true.
    3. At the bottom of the page, click Save Changes.
  2. In the unit where you want to create the component, click html under Add New Component, and then click E-text Written in LaTeX. The new component is added to the unit.
  3. Click Edit to open the new component. The component editor opens.
Image of the HTML component editor with the LaTeX compiler.
  1. In the component editor, click Launch Latex Source Compiler. The LaTeX editor opens.

    Image of the HTML component editor with the LaTeX compiler
  2. Write LaTeX code as needed. You can also upload a LaTeX file into the editor from your computer by clicking Upload in the bottom right corner.

  3. When you have written or uploaded the LaTeX code you need, click Save & Compile to edX XML in the lower-left corner.

    The component editor closes. You can see the way your LaTeX content looks.

    Image of the LaTeX component
  4. On the unit page, click Preview to verify that your content looks the way you want it to in the LMS.

    If you see errors, go back to the unit page. Click Edit to open the component again, and then click Launch Latex Source Compiler in the lower-left corner of the component editor to edit the LaTeX code.