XHTML Interview Questions and Answers for freshers

100 XHTML Interview Questions and Answers for Freshers
  1. What is XHTML?

    • Answer: XHTML (Extensible HyperText Markup Language) is a reformulation of HTML as an XML application. It emphasizes stricter syntax rules than HTML, requiring well-formed XML documents with properly nested and closed tags. This makes XHTML documents more robust and easier to process by XML parsers.
  2. What is the difference between HTML and XHTML?

    • Answer: XHTML is stricter than HTML. It requires well-formed XML, meaning all tags must be properly nested and closed, attributes must be enclosed in quotes, and lowercase tag names are generally preferred. HTML is more forgiving of syntax errors.
  3. What is the DOCTYPE declaration in XHTML?

    • Answer: The DOCTYPE declaration tells the browser which version of XHTML the document conforms to. It's crucial for proper rendering and validation. Examples include ``
  4. Explain XHTML namespaces.

    • Answer: XHTML namespaces help avoid naming conflicts when using elements from different XML vocabularies in a single document. They provide a way to uniquely identify elements and attributes.
  5. What are the different XHTML document types?

    • Answer: XHTML 1.0 offers three DTDs: Strict, Transitional, and Frameset. Strict is the most restrictive, avoiding presentational elements. Transitional allows some presentational elements for backward compatibility. Frameset supports frames.
  6. How do you create a hyperlink in XHTML?

  7. How do you create an image in XHTML?

    • Answer: Using the `` tag with the `src` attribute specifying the image URL and `alt` attribute providing alternative text.
  8. Explain the use of the `

    ` tag in XHTML.

    • Answer: The `

      ` tag represents a paragraph of text.

  9. What is the purpose of the `
    ` tag in XHTML?

    • Answer: The `
      ` tag inserts a single line break.
  10. How do you create a heading in XHTML?

    • Answer: Using the `

      ` to `

      ` tags, with `

      ` being the most important heading and `

      ` the least.
  11. Explain the use of the `

    ` and `` tags.

    • Answer: `
      ` is a block-level element, used for dividing a page into sections. `` is an inline element, used for styling or scripting within a line of text.
  12. How do you create a table in XHTML?

    • Answer: Using the ``, ``, `
      `, and `` tags. `` encloses the table, `` defines a row, `
      ` a table data cell, and `` a table header cell.
    • What is the role of the `

      ` tag in XHTML?

      • Answer: The `` tag creates an HTML form for user input, which can be submitted to a server-side script.
    • How do you create a list in XHTML? (ordered and unordered)

      • Answer: Ordered lists use the `
          ` and `
        1. ` tags. Unordered lists use the `
            ` and `
          • ` tags.
        2. Explain the concept of character encoding in XHTML.

          • Answer: Character encoding specifies how characters are represented in bytes. It's important to declare the encoding in the document's header (e.g., ``) to ensure proper display of characters.
        3. What is XHTML validation?

          • Answer: XHTML validation is the process of checking if an XHTML document conforms to the XHTML specification. This ensures the document is well-formed and follows the syntax rules.
        4. How can you validate your XHTML documents?

          • Answer: Using online validators provided by the W3C or other validation services.
        5. What are some common XHTML validation errors?

          • Answer: Missing closing tags, improperly nested tags, missing quotes around attribute values, incorrect DOCTYPE declaration.
        6. Explain the importance of using CSS with XHTML.

          • Answer: CSS (Cascading Style Sheets) separates content from presentation. Using CSS with XHTML improves maintainability, accessibility, and allows for consistent styling across the website.
        7. How do you link an external CSS stylesheet to an XHTML document?

          • Answer: Using the `` tag within the `` section: ``
        8. What are inline styles in XHTML?

          • Answer: Inline styles are CSS rules applied directly to an HTML element using the `style` attribute. They are generally discouraged for larger projects due to maintainability issues.
        9. What are embedded styles in XHTML?

          • Answer: Embedded styles are CSS rules defined within the `