Highlighting text inside HTML tag

Syntax highlighting, code folding, brace matching, code indenting, and function list

Highlighting text inside HTML tag

Postby ahy1980 » Sun Sep 27, 2009 12:13 am

I'm trying to figure out how to get text inside of an HTML tag highlighted. Did some searching didn't find an answer.

For example: <table width="300px" class="highlightme">

How do I get the 'highlightme' part to be highlighted?
ahy1980
Newbie
 
Posts: 2
Joined: Sun Sep 27, 2009 12:08 am

Re: Highlighting text inside HTML tag

Postby pietzcker » Sun Sep 27, 2009 8:31 am

<edit>Removed this incorrect and speculative post. Mofi, please delete :)</edit>
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Highlighting text inside HTML tag

Postby Mofi » Sun Sep 27, 2009 11:20 am

The default wordfile html.uew for syntax highlighting HTML content has at top the line:

/L3"HTML" HTML_LANG Nocase Noquote Block Comment On = <!-- Block Comment Off = --> File Extensions = HTM HTML ...

Noquote means do not search for strings and highlight them with the color for strings. The reason is quite simple, in HTML often all attribute values are double quoted and with enable highlighting of strings also the standardized values of attributes would be highlighted as strings.

Well, for my HTML files I have enabled highlighting of DOUBLE QUOTED strings by using following in my HTML wordfile:

/L3"HTML" HTML_LANG Nocase Block Comment On = <!-- Block Comment Off = --> String Chars = " EnableMLS File Extensions = HTM HTML ...

UltraEdit and UEStudio highlights for me everything between two double quote characters with the strings color, even when such a string starts on line X and ends on line Y because the values of alt=, title= and others are sometimes so long that I write them over multiple lines.

But this highlighting is fine for me only because I never use double quote characters for standard attribute values or within the text displayed later in the browser. I use &quot; when I need a double quote character in the displayed text. In HTML 4.01 specification is defined that numbers and string values containing only letters, digits and some other characters must not be quoted. Of course for most attributes the string value must always start with a letter. For details see quotation marks around attribute value in the HTML 4.01 standard. And I use this freedom and double quote only class names, URIs, anchor names, alternate text and title text. And when I must quote a value, for example when using a percentage value for the width attribute, I quote them with single quotes, for example width='50%'. According to my syntax highlighting definition single quoted strings are not highlighted by UE/UES and therefore I get 50% highlighted as number.

By the way: width="300px" is invalid HTML and therefore ignored by the browsers when using STRICT mode. I know many, many WYSIWYG HTML editors output width and height length values with the unit px into HTML files which is the reason why I think that most programmers of WYSIWYG HTML editors have never read the HTML specification. HTML supports only 3 type of length values for the width and height attributes: just a number (= pixel value) quoted with double or single quotes or not quoted, or a quoted percentage value with % after the number, or a quoted relative number with a * after the number. "px" is a CSS unit and not allowed in any length value of an HTML attribute.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Highlighting text inside HTML tag

Postby ahy1980 » Sun Sep 27, 2009 11:57 am

Thanks for the detailed explanation Mofi. The tip on HTML standards was interesting as well!
ahy1980
Newbie
 
Posts: 2
Joined: Sun Sep 27, 2009 12:08 am


Return to Syntax Highlighting