Setting dir=“rtl” in <html> tag doesn't seem to work, works in <h:body>

时光毁灭记忆、已成空白 提交于 2019-12-11 10:53:46

问题


I want to write the text of a JSF with dir="rtl" (Right To Left) when a condition is satisfied. I have checked in a HTML file that if you write in the html tag dir="rtl", like this:

<html dir=rtl">

All the pages tags are set dir="rtl", without having to write dir="rtl" in each tag.

But when I write in my XTHML file the following code, and the condition is false but it does not work, the pages tags are NOT set dir="rtl".

<html  
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    dir="#{languageSwitcher.dirWriting() == true ? 'ltr' : 'rtl'}">

At first I thought that it could be because html tag can not accept EL (Expression Language) so I tried to write the following code to check if it worked, but again I had the same, problem the pages tags are NOT set dir="rtl", so I guess that html tag not accepting EL is not the problem.

<html  
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
    dir="rtl">

Instead if I write in the body tag:

<h:body  dir="#{languageSwitcher.dirWriting() == true ? 'ltr' : 'rtl'}">

It works

Why if I write it in the html tag it does not work?

UPDATE:

When I view the html code with my browser (View source code) this is what I see:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<head>

If I view it using Firebug this is what I see:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

来源:https://stackoverflow.com/questions/30646177/setting-dir-rtl-in-html-tag-doesnt-seem-to-work-works-in-hbody

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!