locked
How do I select multiple tags without also selecting their container? RRS feed

  • Question

  • Sorry to ask such a silly question, but I'm trying to figure out how to select multiple tags (in my case, P tags) that are enclosed in other tags.

    In my case, I have a very large but simple table, which has columns of text wrapped in paragraph tags that I want to apply a style to. (Note that this question could also apply to other tag types).

    I can apply to just one tag at a time fine, but when I try to extend the selection to, say, the previous row's text, EW selects the entire TD structure, and I have to then apply the style to the whole data element, instead of just the text element within that cell.

    Unfortunately, not every cell contains text I wish to style the same way, so I need to be able to do the equivalent of CTRL-clicking the element (similar to how Word works). (I do want to select an entire P tag's text, not parts of it.)

    Is there a way to do this within EW? Am I missing something really obvious that would be a better approach?

    My alternative/workaround is to manually edit the file in my favourite text editor, and/or perform a search-and-replace and try to ensure that I change the appropriate text elements (which is fairly difficult with the way EW colours/highlights text when the editor window isn't selected). But this will take hours and hours to perform, so I'm hoping there's a better/easier way.

    Thanks in advance for any suggestions!

    Monday, June 11, 2012 5:42 AM

Answers

  • I believe the answer is that you can't. 

    You select and apply a style to a <p> or to  multiple <p>'s inside a cell (or a div, or a ....); you can apply a style to the containing <td>.  You can't select some <p>'s inside one cell and at the same time other <p>'s inside another cell and apply a style to all those <p>'s.

    If most of the text is one style, in your CSS file, create a style for <td> that decribes that style.  Create other styles for exceptions to the predominant style, and select the <p>'s with the exceptions to the main style, and apply those exceptions where needed.

    • Marked as answer by PC Pete Wednesday, June 13, 2012 3:05 PM
    Monday, June 11, 2012 1:51 PM

All replies

  • That's why you create a class in your css section or external style sheet and apply that class to the tags you want to assign it to.

    Expression Web MVP


    Monday, June 11, 2012 1:03 PM
  • I believe the answer is that you can't. 

    You select and apply a style to a <p> or to  multiple <p>'s inside a cell (or a div, or a ....); you can apply a style to the containing <td>.  You can't select some <p>'s inside one cell and at the same time other <p>'s inside another cell and apply a style to all those <p>'s.

    If most of the text is one style, in your CSS file, create a style for <td> that decribes that style.  Create other styles for exceptions to the predominant style, and select the <p>'s with the exceptions to the main style, and apply those exceptions where needed.

    • Marked as answer by PC Pete Wednesday, June 13, 2012 3:05 PM
    Monday, June 11, 2012 1:51 PM
  • Thank you Kathy, that's a great explanation as to what the solution might be. You're right of course - given the constraints, it's a better way to go using a <td> style and manually restyle the few exceptions, than trying to get a perfect result without some hard work!

    Cheers,

    Pete

    Wednesday, June 13, 2012 3:08 PM